M
Martin
Hello,
I am new to Excel programming and wondered if there is a more efficient way
of writing some code. Here is my existing code:
If Range("B7").Value = Region Then Rows("7:7").Hidden = False Else
Rows("7:7").Hidden = True
If Range("B8").Value = Region Then Rows("8:8").Hidden = False Else
Rows("8:8").Hidden = True
If Range("B9").Value = Region Then Rows("9:9").Hidden = False Else
Rows("9:9").Hidden = True
If Range("B10").Value = Region Then Rows("10:10").Hidden = False Else
Rows("10:10").Hidden = True
If Range("B11").Value = Region Then Rows("11:11").Hidden = False Else
Rows("11:11").Hidden = True
If Range("B12").Value = Region Then Rows("12:12").Hidden = False Else
Rows("12:12").Hidden = True
If Range("B13").Value = Region Then Rows("13:13").Hidden = False Else
Rows("13:13").Hidden = True
If Range("B14").Value = Region Then Rows("14:14").Hidden = False Else
Rows("14:14").Hidden = True
If Range("B15").Value = Region Then Rows("15:15").Hidden = False Else
Rows("15:15").Hidden = True
If Range("B16").Value = Region Then Rows("16:16").Hidden = False Else
Rows("16:16").Hidden = True
If Range("B17").Value = Region Then Rows("17:17").Hidden = False Else
Rows("17:17").Hidden = True
Rather than copy this for each row is there a way to say something like
start at row 7 and loop until row 17.
The spreadsheet has many headers so I will need to replicate this from rows
20 to 30, rows 28 to 35 etc etc rather than all rows.
Any advice would be greatly appreciated.
Martin
I am new to Excel programming and wondered if there is a more efficient way
of writing some code. Here is my existing code:
If Range("B7").Value = Region Then Rows("7:7").Hidden = False Else
Rows("7:7").Hidden = True
If Range("B8").Value = Region Then Rows("8:8").Hidden = False Else
Rows("8:8").Hidden = True
If Range("B9").Value = Region Then Rows("9:9").Hidden = False Else
Rows("9:9").Hidden = True
If Range("B10").Value = Region Then Rows("10:10").Hidden = False Else
Rows("10:10").Hidden = True
If Range("B11").Value = Region Then Rows("11:11").Hidden = False Else
Rows("11:11").Hidden = True
If Range("B12").Value = Region Then Rows("12:12").Hidden = False Else
Rows("12:12").Hidden = True
If Range("B13").Value = Region Then Rows("13:13").Hidden = False Else
Rows("13:13").Hidden = True
If Range("B14").Value = Region Then Rows("14:14").Hidden = False Else
Rows("14:14").Hidden = True
If Range("B15").Value = Region Then Rows("15:15").Hidden = False Else
Rows("15:15").Hidden = True
If Range("B16").Value = Region Then Rows("16:16").Hidden = False Else
Rows("16:16").Hidden = True
If Range("B17").Value = Region Then Rows("17:17").Hidden = False Else
Rows("17:17").Hidden = True
Rather than copy this for each row is there a way to say something like
start at row 7 and loop until row 17.
The spreadsheet has many headers so I will need to replicate this from rows
20 to 30, rows 28 to 35 etc etc rather than all rows.
Any advice would be greatly appreciated.
Martin