Wed 4 Mar, 2015 12:19 am
I have following code to hide / unhide columns (few lines I have provided). The columns spread upto about 3500 and each 10 columns or even less are grouped to show the details of the group named in columnB2:B325. On enering value 1 or 0 It is hiding or unhiding. The code is meeting my requirements. But what I am looking is on unhiding a group of columns I want cursor to go to the first row of the column after scrolling to a column number for eg. in E:N cursor should be in E and I should be in a position to view the expanded columns and scroll further. I tried entering "Range("E1").Select" but on running the code, the cursor will be in E1 but I will not be in a position to scroll further. If the column number is 3000, it should scroll and show the selected column number.
If posiible to simplify the code let me know. as it is not having fixed ccolumn numbers I think it may not be possible to use array.
Any Help please.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("$C2:C325")) Is Nothing Then
If Range("C2").Value = 1 Then
Columns("E:N").EntireColumn.Hidden = True
If Range("C2") = 0 Then
Columns("E:N").EntireColumn.Hidden = False
If Range("C3").Value = 1 Then
Columns("P:W").EntireColumn.Hidden = True
If Range("C3") = 0 Then
Columns("P:W").EntireColumn.Hidden = False
....... & it goes on like this