Hi, i am trying to understand a macro i used previously and try and update the macro so i can use it now.
what this macro did, was to look at cells in row 1, and if the cell value = "Hide" the the macro would hide the entire column.
What I am looking at now, is changing this macro to look at all cells in row 4, from column A to column BZ, and if the cell value = "Hide", then the entire column will be hidden.Sub Hide_Columns() Dim a As Long, c As Long, d As Long, e As Long Dim b As String, f As String For a = 1 To Sheets.Count b = Worksheets(a).Name If b = "Overview" Or b = "Sheet1" Or b = "Sheet2" Then c = Worksheets(a).Cells(1, Columns.Count).End(xlToLeft).Column d = Worksheets(a).Cells(Rows.Count, 1).End(xlUp).Row For e = 1 To c If Worksheets(a).Cells(1, e) = "Hide" Then f = Chr(e + 64) Worksheets(a).Range(f & 1 & ":" & f & d).EntireColumn.Hidden = True End If Next e End If Next a MsgBox "Completed" End Sub
I can't figure out which bits of the macro are doing what. Any help would be greatly appreciated.
Thanks,
Thomas
Last edited by Leith Ross; 10-06-2009 at 11:25 AM. Reason: Added Code Tags
sorry, i accidently originally posted this as "solved". can anybody help with this macro?
Hello strongarmtom,
To make your posts easier to read, copy, and edit please wrap your code. I did it for you this time. Here is how you can do
it next time.
How to wrap your Code
1. Select all your code using the mouse.
2. Click on the # icon on the toolbar in the Message window. This will automatically wrap the text you selected
with the proper Code tags to create a Code Window in your post.
Use the Bulletin Board Code Tags
[code] at the start of the first line,
[/code] at the end of the last line.
To learn more about BB codes used in this forum, just click on the link below...
Bulletin Board Markup Codes
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
OK. Thanks Leith.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks