I'd really appreciate it if someone could point me to the right direction. I'm trying to do a simple macro to hide selected set of rows. I could combine Set 1 and 2 in the variables, but they are two different sets of information and I want them separated so it is easier to maintain as the code grows.
I'm wondering if there are ways to see how range resolves my variables.
This code works
Const Set1 As String = "1:2,4:5"
Const Set2 As String = "7:8,11:12"
Sub test()
Worksheets("Sheet1").Range(Set1).EntireRow.Hidden = True
Worksheets("Sheet1").Range(Set2).EntireRow.Hidden = True
End Sub
Sub test2()
Worksheets("Sheet1").Range("1:2,4:5,7:8,11:12").EntireRow.Hidden = True
End Sub
But not this
Const Set1 As String = "1:2,4:5"
Const Set2 As String = "7:8,11:12"
Sub test()
Worksheets("Sheet1").Range(Set1, Set2).EntireRow.Hidden = True
End Sub
testapproach? The last one doesn't work because passing two arguments to Range() implies they are the top-left and bottom-right corners of a larger range.