Macro to hide all columns without anything in then from columnA to Bz

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,
I need a macro to hide all columns and all rows that do not contain any values within this range (A1:Bz200)

i thought it would be easy but get stuck

Tony
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Try:
Code:
Sub hideRowsCols()
    Range("A1:A200").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden = True
    Range("A1:BZ1").SpecialCells(xlCellTypeBlanks).EntireColumn.Hidden = True
End Sub
 
Upvote 0
Special cells, Knew i'd missed something, that's twice in one day you have saved me thank you so much :)

Tony
 
Upvote 0
Oh dear I know I had over simplified my request so sorry
what I meant was that row 1 has formulas in it and I want to hide the columns that formulas =""
sorry but any ideas?

Thanks

Tony
 
Upvote 0
Will all the blank rows also have formulas in them that return "" or just row 1?
 
Upvote 0
Try this:

Code:
Sub Check_For_Formulas()
'Modified 3-5-18 11:55 AM EST
Application.ScreenUpdating = False
Dim LastColumn As Long
LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column
Dim cell As Range
    For Each cell In Range(Cells(1, LastColumn), Cells(1, 1))
Select Case True
Case cell.HasFormula
If cell.Value = "" Then
Columns(cell.Column).Hidden = True
Else
Columns(cell.Column).Hidden = False
End If
End Select
Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,942
Members
449,094
Latest member
teemeren

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