Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 386
Default Hide Cols ??


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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Hide Cols ??


looks ok to me

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

in Excel 2003 and 2007 ONLY these columns get hidden.



"LiAD" wrote in message
...
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Hide Cols ??


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.

LiAD wrote:

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


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Hide Cols ??


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


"LiAD" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Enhance sub to copy cols of variable length into 1 col to snake results into other cols Max Excel Programming 1 August 7th 08 02:03 PM
2 Cols To 2 Cols VLookup Comparison CuriousMe Excel Discussion (Misc queries) 4 December 21st 06 07:54 PM
Range.Select 1st pass 13 cols, 2nd paqss 25 cols twice as wide in error? Craigm[_53_] Excel Programming 2 May 2nd 06 11:04 AM
Cond Format:re color 2 cols, skip 2 cols Tat Excel Worksheet Functions 2 June 22nd 05 06:43 PM
Hide Unused Cols & Rows in a Range Bob Maloney Excel Programming 2 July 31st 03 12:39 PM


All times are GMT +1. The time now is 09:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"