hiding columns in excel based on formula result

H

hjbrooks2002

Hi - I am trying to create a macro that will hide columns if date
(that is the column heading) is in the past, i.e. if column heading is
less than "Now()" then hide the column (the spreadsheet application is
a gantt chart of sorts for tracking resource utilization). Do you have
any idea how to do this?

I see lots of links for macros that hide rows or colunns based on
specific values but none for formula results. Please help!! thanks :)
 
D

Don Guillett

try this. Change cells(1,5) to suit. You may want 1,1

Sub HideColumnsBeforeToday()
x = Rows(1).Find(Date, After:=Cells(1, 1), LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext).Column
Range(Cells(1, 5), Cells(1, x)).EntireColumn.Hidden = True
End Sub
 

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

Top