Hide Cols ??

L

LiAD

Hi,

Using the recorder I got the following macro to try to hide cols G to L.

Columns("G:L").Select
Selection.EntireColumn.Hidden = True

When I run the macro it hides from col B to col M inclusive. I have tried
unmerging any cells in these cols that overlap with the range I want to hide
etc but it makes no difference.

How do I get a code to hide the cols i wish?
Thanks
 
P

Patrick Molloy

looks ok to me

Columns("G:L").EntireColumn.Hidden = True

in Excel 2003 and 2007 ONLY these columns get hidden.
 
D

Dave Peterson

I bet you have merged cells that span B:M (including G:L).

If you remove those merged cells, then your code will work ok.
 
E

EricG

Here's a routine you can use to locate merged cells. It shades the cells a
certain color. You could also change the border or do something else
instead...

HTH,

Eric

'
' Finds and marks all merged cells in the used range
' of a worksheet.
'
Sub MarkMergedCells()
Dim rsel As Range, r As Range
'
Set rsel = Nothing
For Each r In ActiveSheet.UsedRange
If r.MergeCells = True Then
If rsel Is Nothing Then
Set rsel = r
Else
Set rsel = Union(rsel, r)
End If
End If
Next

If rsel Is Nothing Then
Else
rsel.Interior.ColorIndex = 3
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top