Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro - hides everything and not just certain columns as recorded

Hi

I have a problem that when I play the following macros, it hide
everything, and I mean everything and not just the columns a
recorded.

Sub hide()
'
' hide Macro
' Macro recorded 2004/05/02 by
'
' Keyboard Shortcut: Ctrl+h
'
Columns("M:O").Select
Selection.EntireColumn.Hidden = True
Columns("X:Z").Select
Selection.EntireColumn.Hidden = True
Columns("AI:AK").Select
Selection.EntireColumn.Hidden = True
Columns("AT:AV").Select
Selection.EntireColumn.Hidden = True
Columns("BE:BG").Select
Selection.EntireColumn.Hidden = True
Columns("BP:BR").Select
Selection.EntireColumn.Hidden = True
Columns("CA:CC").Select
Selection.EntireColumn.Hidden = True
Columns("CF:CF").Select
Selection.EntireColumn.Hidden = True
Columns("CM:CM").Select
Selection.EntireColumn.Hidden = True
Columns("CR:CR").Select
Selection.EntireColumn.Hidden = True

End Sub

What can I do to make sure it only hides these columns and nothin
more.
:confused

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default macro - hides everything and not just certain columns as recorded

One way:

Public Sub Hide()
Range("M:O,X:Z,AI:AK,AT:AV,BE:BG,BP:BR,CA:CC,CF:CF ,CM:CM,CR:CR") _
.EntireColumn.Hidden = True
End Sub


Note that there's almost never a need to select a range - you can use
the range object directly

In article ,
sonar wrote:

Hi

I have a problem that when I play the following macros, it hides
everything, and I mean everything and not just the columns as
recorded.

Sub hide()
'
' hide Macro
' Macro recorded 2004/05/02 by
'
' Keyboard Shortcut: Ctrl+h
'
Columns("M:O").Select
Selection.EntireColumn.Hidden = True
Columns("X:Z").Select
Selection.EntireColumn.Hidden = True
Columns("AI:AK").Select
Selection.EntireColumn.Hidden = True
Columns("AT:AV").Select
Selection.EntireColumn.Hidden = True
Columns("BE:BG").Select
Selection.EntireColumn.Hidden = True
Columns("BP:BR").Select
Selection.EntireColumn.Hidden = True
Columns("CA:CC").Select
Selection.EntireColumn.Hidden = True
Columns("CF:CF").Select
Selection.EntireColumn.Hidden = True
Columns("CM:CM").Select
Selection.EntireColumn.Hidden = True
Columns("CR:CR").Select
Selection.EntireColumn.Hidden = True

End Sub

What can I do to make sure it only hides these columns and nothing
more.



---
Message posted from http://www.ExcelForum.com/

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro - hides everything and not just certain columns as recorded

Hi

I replaced the one I had with the one you gave and I got a sinte
error. Did I do something wrong

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default macro - hides everything and not just certain columns as recorded

J.E.'s code worked for me when I copied from the post to the VBE.

Any chance you introduced extraneous characters (or left some out)?

You may want to post what you pasted.

"sonar <" wrote:

Hi

I replaced the one I had with the one you gave and I got a sintex
error. Did I do something wrong?

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default macro - hides everything and not just certain columns as recorded

In article ,
sonar wrote:

I replaced the one I had with the one you gave and I got a sintex
error. Did I do something wrong?


Yes. But I don't know what.

Did you include the line extension characters (" _", space-underscore)
at the end of the long line?

Try copying and pasting.
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
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
How to FIX Recorded Macro JMay Excel Discussion (Misc queries) 7 May 23rd 07 04:13 AM
Recorded Macro want to know New Users to Excel 5 February 14th 07 12:46 PM
When i hide columns it hides whole sheet CathyL Excel Discussion (Misc queries) 1 June 15th 06 07:51 PM
Button hides unhides columns, how? JimH Excel Discussion (Misc queries) 3 April 20th 05 09:59 PM


All times are GMT +1. The time now is 02:24 PM.

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"