HELP! - Hiding colums Macro

mobilesuit818

New Member
Joined
Sep 13, 2006
Messages
48
Hello,
I need to hide several columns (those columns are F, Q, R S, T, U, W, X, and Y) when im finished working a worksheet. There are several worksheets in my workbook.

Can someone help with a macro for this, please?
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
How's this:

<font face=Tahoma><SPAN style="color:#00007F">Sub</SPAN> HideColumns()
    <SPAN style="color:#00007F">Dim</SPAN> ws <SPAN style="color:#00007F">As</SPAN> Worksheet
        <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> ws <SPAN style="color:#00007F">In</SPAN> ActiveWorkbook.Worksheets
            ws.Range("F:F, Q:Y").EntireColumn.Hidden = <SPAN style="color:#00007F">True</SPAN>
        <SPAN style="color:#00007F">Next</SPAN> ws
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Just set to False to unhide.

HTH,

Smitty
 
Upvote 0
Thank you
Where do you input this. In what Module?
Also, once I copy and paste, do I need to save?
So what would initiate the Macro or how do I get the macro to work.?
 
Upvote 0
In the VBE just got Insert-->Module and paste the code there.

Yes, you'll need to save the workbook in order to save the code.

As for getting it to work, you can call the macro from the Macro menu, assign it to a keyboard shortcut, draw a Forms button and assign it to that, or tie it to an event.

Smitty
 
Upvote 0
Actually, what would the formula be if I just wanted to use this only on single worksheet in a workbook, instead of the entire workbook?

Is there a macro that I can run to undo it?


Can anyone help me with these?
 
Upvote 0
Code:
Sub foo()
  ActiveSheet.Range("F:F, Q:Y").EntireColumn.Hidden = True
End Sub

But you've got your terminology a bit mixed up. The above code will only act on the Active Worksheet, whereas the other will work on every Worksheet in the entire Workbook.

Smitty
 
Upvote 0

Forum statistics

Threads
1,214,805
Messages
6,121,665
Members
449,045
Latest member
Marcus05

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top