Hi, so i have the following data, this is just a little bit of the document. The chainage just relates to a marker post on the road e.g. chainage 53.5 = 53.5 km along the road.
Anyway i am trying to make vba code that searches for any folder that holds information about a section of road. Say the section was chainage 50 to chainage 57, the relevant folders would be any that have either the "chainage start" or the "chainage end" within these boundaries (001,003,005,008).
Below this data, i have written the code i have already got, the problem i am having is that at the moment both the "chainage start" value and the "chainage end" value have to be within this range but i want it to be either one or both of them values are in it as i am loosing valuable information.
Any way to basically change the and to or? Thank you for the help in advance.
Anyway i am trying to make vba code that searches for any folder that holds information about a section of road. Say the section was chainage 50 to chainage 57, the relevant folders would be any that have either the "chainage start" or the "chainage end" within these boundaries (001,003,005,008).
Below this data, i have written the code i have already got, the problem i am having is that at the moment both the "chainage start" value and the "chainage end" value have to be within this range but i want it to be either one or both of them values are in it as i am loosing valuable information.
Any way to basically change the and to or? Thank you for the help in advance.
Road | Folder | Chainage Start | Chainage End |
A66 | A66-001 | 53.5 | 65.5 |
A66 | A66-002 | ||
A66 | A66-003 | 53.5 | 65.5 |
A66 | A66-004 | 77 | 79.5 |
A66 | A66-005 | 52.5 | 55.5 |
A66 | A66-006 | ||
A66 | A66-007 | ||
A66 | A66-008 | 48 | 54.5 |
A66 | A66-009 | ||
A66 | A66-010 | 45 | 49.5 |
Code:
Sub Filter()
Sheets("FolderSort").Select
ActiveSheet.AutoFilterMode = False
ActiveSheet.Range("$I$4:$J$368").AutoFilter Field:=1, Criteria1:=">=" & Sheets("FrontPage").Range("E17").Value, _
Operator:=xlAnd, Criteria2:="<=" & Sheets("FrontPage").Range("K17").Value
ActiveSheet.Range("$I$4:$J$368").AutoFilter Field:=2, Criteria1:=">=" & Sheets("FrontPage").Range("E17").Value, _
Operator:=xlAnd, Criteria2:="<=" & Sheets("FrontPage").Range("K17").Value
End Sub
Last edited by a moderator: