Hi everyone,
I had great success with my last query on this site (thanks to the great experts here!) and I have another VBA problem which I’m struggling with.
Basically I have data in columns E to AH (30 columns total), every ten columns is a new category for me.
Categories are as follows:- E:N is Report 1, O:X is Report 2, Y:AH is Report 3
In these reports categories I have the 10 results, E – Report 1, results 1, F – Report 1, Results 2, G- Report 1, Results 3 etc.
Cells A2 is the number of reports and A3 is the number of results.
For example if I had 2 reports but 3 results I would want columns E, F, G (from report 1), and O, P, Q( from report 2) to be shown and the rest of the columns in these report categories to be hidden and all of report 3 results to be hidden.
I can figure out how to code for values based in one cell but they don't interact well with each other as I'm telling it to show/hide cloumns at the same time
Here's my code for showing the reports columns:
And here's an example of what my hiding/unhiding the results columns looks like
I hope I'm not going about this in all the wrong way but any pointers or tips would be greatly appreciated.
Thanks!
I had great success with my last query on this site (thanks to the great experts here!) and I have another VBA problem which I’m struggling with.
Basically I have data in columns E to AH (30 columns total), every ten columns is a new category for me.
Categories are as follows:- E:N is Report 1, O:X is Report 2, Y:AH is Report 3
In these reports categories I have the 10 results, E – Report 1, results 1, F – Report 1, Results 2, G- Report 1, Results 3 etc.
Cells A2 is the number of reports and A3 is the number of results.
For example if I had 2 reports but 3 results I would want columns E, F, G (from report 1), and O, P, Q( from report 2) to be shown and the rest of the columns in these report categories to be hidden and all of report 3 results to be hidden.
I can figure out how to code for values based in one cell but they don't interact well with each other as I'm telling it to show/hide cloumns at the same time
Here's my code for showing the reports columns:
Code:
If Range("A2") = "1" Then
Columns("O:AH").Hidden = True
Columns("E:N").Hidden = False
ElseIf Range("A2") = "2" Then
Columns("Y:AH").Hidden = True
Columns("E:X").Hidden = False
ElseIf Range("a2") = "3" Then
Columns("E:AH").Hidden = False
ElseIf Range("A2") = "" Then
Columns("E:AH").Hidden = False
End If
And here's an example of what my hiding/unhiding the results columns looks like
Code:
If Range("A3") = "1" Then
Columns("F:H", "P:X", "Z:AH").Hidden = True
Columns("E", "O", "Y").Hidden = False
ElseIf Range("A3") = "2" Then
Columns("g:H", "q:X", "aa:AH").Hidden = True
Columns("E:f", "O:p", "Y:x").Hidden = False
End If
I hope I'm not going about this in all the wrong way but any pointers or tips would be greatly appreciated.
Thanks!