Hiding specific row/column range in a list/array/other

jonathan9879

New Member
Joined
Aug 21, 2015
Messages
1
I just started with VBA and am currently struggling to find a solution to this problem:

I understand how hiding works and have code for hiding one range of rows/columns (Worksheets("Sheet3").Columns("A:G").EntireColumn.Hidden = True), but I wanted to be able to store a "list" of column + sheet and a list of rows + sheet. Then run the hiding code in a loop for every range in both lists.

I have no idea even where to start.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
You would need to put a list of sheet names in say Column A of your master sheet
And a list of column numbers or letter in say column B of your master sheet
And a list of row numbers in say column C of your master sheet
Then you could write your script similar to the below one.
This script below is just a sample and will not run.
This gives you an ideal.
Code:
Sub Test()
Application.ScreenUpdating = False
Dim i As Integer
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 2 To Lastrow
'To hide sheets
Sheets(Cells(i, 1).Value).Visible = False
'To hide row on sheet
Rows(Cells(i, 2).Value).Hidden = True
'To hide row on specific sheet
Sheets(Cells(i, 1).Value).Rows(Cells(i, 2).Value).Hidden = True

Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,906
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