View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default Show all, but leave the cursor where it is

I ran this code with the cursor in G3. It stayed in G3 during the hide and
unhide process.

Sub hidn()
Dim arr As Variant
Dim i As Long
arr = Array("d:d", "f:f", "h:h", "j:j")
For i = LBound(arr) To UBound(arr)
Columns(arr(i)).EntireColumn.Hidden = True
Next
'MsgBox "Check" 'For testing only
For i = LBound(arr) To UBound(arr)
Columns(arr(i)).EntireColumn.Hidden = False
Next
End Sub


"Annette" wrote:

I used the macro below to hide columns, but want to add code that says
unhide all columns and leave the cursor where it is before the below code is
run. How would I add that into this macro? (I don't want to use 'custom
view' because the cursor is left exactly where the view was saved)

Dim arr As Variant
Dim i As Long
arr = Array("d:d", "f:f", "h:h", "j:j")
For i = LBound(arr) To UBound(arr)
Columns(arr(i)).EntireColumn.Hidden = True
Next