View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Help with hiding columns

Demo'd from the immediate Window:

cells(20,"AA").Activate
? Left(ActiveCell.Address(0,0),1 - (ActiveCell.Column 26))
AA
Cells(3,"B").Select
? Left(ActiveCell.Address(0,0),1 - (ActiveCell.Column 26))
B

Sub BBCC()

For i = 1 To 10
If i Mod 2 = 0 Then
Columns(i).Hidden = True
End If
Next

MsgBox "Take a Look"

For i = 1 To 10
If i Mod 2 = 0 Then
Columns(i).Hidden = False
End If
Next

End Sub

works fine for me.

--
regards,
Tom Ogilvy

"ExcelDave" wrote in message
...
I have two questions

1) Is there a built-in VBA or Excel function that returns the Column

Letter
for any given cell?

2) I would like to know the best way to hide/unhide columns using VBA. I
wrote a For...Next loop using the Sheet.EntireColumn.Hidden = True and it
worked fine until I went to unhide it. It gave me the generic 1004 error.

Any help would be appreciated!