Hide/Unhide Columns

Reply 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.

Sample code...

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
End If
If Range("C2") = 0 Then
Columns("E:N").EntireColumn.Hidden = False
End If

If Range("C3").Value = 1 Then
Columns("P:W").EntireColumn.Hidden = True
End If
If Range("C3") = 0 Then
Columns("P:W").EntireColumn.Hidden = False
End If

....... & it goes on like this

  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Question • Score: 0 • Views: 979 • Replies: 0
No top replies


Related Topics

HVAC lines - Question by alevythiebaut
css - Question by keerthi60
Random Walk in Python Code - Question by Cbr600
Hacked on Facebook - Question by Hopea
need help with this code - Question by Philoue
Help with a Code - Question by Joshua5
  1. Forums
  2. » Hide/Unhide Columns
Copyright © 2021 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 05/07/2021 at 02:30:05