Macro hiding the wrong columns!

SamAnnElizabeth

New Member
Joined
Mar 15, 2013
Messages
34
I'm trying to record a macro to return my sheet to the print display. I recorded it and then edited in visual basic. Here's the code:

Sub Hide()
'
' Hide Macro
'


'
Rows("1:60").Select
Selection.EntireRow.Hidden = False
Columns("A:AZ").Select
Selection.EntireColumn.Hidden = False
Rows("34:51").Select
Selection.EntireRow.Hidden = True
Rows("3:9").Select
Selection.EntireRow.Hidden = True
Columns("K:K").Select
Selection.EntireColumn.Hidden = True
Columns("P:P").Select
Selection.EntireColumn.Hidden = True
Columns("AG:AX").Select
Selection.EntireColumn.Hidden = True
Range("A1").Select
End Sub


When I run it, it hides columns G:Q and Z:AX. The rows are right. I have no merged cells in the range. Does anyone have any ideas what I could do differently? Thanks!
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
What is it that is wrong?

You say the wrong columns are hidden, which columns are you expecting to be hidden?


You can write the code without selecting anything
Code:
Sub Hide()
'
' Hide Macro
'

'
Rows("1:60").EntireRow.Hidden = False
Columns("A:AZ").EntireColumn.Hidden = False
Rows("34:51").EntireRow.Hidden = True
Rows("3:9").EntireRow.Hidden = True
Columns("K:K").EntireColumn.Hidden = True
Columns("P:P").EntireColumn.Hidden = True
Columns("AG:AX").EntireColumn.Hidden = True
Range("A1").Select
End Sub
 
Last edited:
Upvote 0
By Clear Filtering, do you mean turn OFF any filters (dropdowns no longer visible)?
Oor just clear any criteria that had been selected by the filters?
 
Upvote 0
This line will clear any criteria that has been set by autofilters

ActiveSheet.ShowAllData
 
Upvote 0
Ugh, I'm having another problem now.

I tried to insert a button for the Macro and it's now telling me that there is an error with the ActiveSheet.ShowAllData command when there wasn't before I tried to add the button.

Any advice?
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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