Macro that will hidden columns, rows and worksheets based on an identifier

  • Thread starter Thread starter treen333
  • Start date Start date
T

treen333

I'm creating a wookbook where each row is indentified to a different
project as well as two columns and two work sheets. I need to hide the
rows, columns and worksheet for project A when viewing project B and
vis versa. I would like to create a macro to do this but I'm running
out of ideas. Can any one out there help?

Please note I am experienced in Excel but it is from hands on
experience so some highly technical terms may confuse me.

Thanks
Treen
 
Use one of these ideas in the sheet module where cell a1 contains the number
of
the month. This was for specific months

Sub hidecols()
Columns.Hidden = False
mc = Range("a1") + 1
Range(Cells(1, mc), Cells(1, 12)).EntireColumn.Hidden = True
End Sub

'Automatic every time you change cell a1
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$A$1" Then Exit Sub
Columns.Hidden = False
mc = Target + 1
Range(Cells(1, mc), Cells(1, 12)).EntireColumn.Hidden = True
End Sub
 
Try Tools > Macro > RecordNewMacro > and follow the menus and then actually
hide the columns you wish for one instance by hand and then stop
recording....you now have a macro to do that action again any time you need
it.....then do the same to clear all the hidden columns, and a third macro to
hide the other set of columns.....if you have trouble, post back.....

hth
Vaya con Dios,
Chuck, CABGx3
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top