Macro that looks at cell contents

andrewb90

Well-known Member
Joined
Dec 16, 2009
Messages
1,077
Hi all,

I want to be able to have the user hit a macro button and it will unhide columns C:K but only if there is data in somewhere between rows 10:20.
Is this possible to do?

Thanks,

Andrew
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Add a row (A) at the top of the sheet where you calculate a one in the column where there is data in that particular column.
Use the code below to hide/unhide columns

Code:
For Each c in Range("A1:Z1")
  If c.Value = 1 Then
    c.EntireColumn.Hidden = True
  Else
    c.EntireColumn.Hidden = False
  End If
Next c
 
Upvote 0
When there is data in range A10:A20, then calculate a value 1 for A1.

The macro looks at all cells in the range A1:Z1 and will hide column A as cell value of A1 equals 1.
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,754
Members
452,940
Latest member
rootytrip

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