ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hide Columns (https://www.excelbanter.com/excel-programming/301763-hide-columns.html)

rickey24[_4_]

Hide Columns
 
Hi all

The setup is I have weekdays listed starting with June 1st in C6 goin
horizontal across the whole sheet to IV6. I wanted to do
workbook_open event where it takes whatever today's date is and hide
the columns From C6 through yesterday. Essentially so today's colum
will be right next to the B column. So if today's date is in H6, C6-G
would become hidden when one were to open the workbook.

Thanks so much for the insight.
B

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Hide Columns
 
Range("C6:IV6").EntireColumn.Hidden = False
res = application.Match(clng(Date-1),Range("C6:IV6"),0)
if not res is nothing then
Range("C6",Range("C6:IV6")(res)).EntireColumn.Hidd en = True
End if

--
Regards,
Tom Ogilvy

"rickey24 " wrote in message
...
Hi all

The setup is I have weekdays listed starting with June 1st in C6 going
horizontal across the whole sheet to IV6. I wanted to do a
workbook_open event where it takes whatever today's date is and hides
the columns From C6 through yesterday. Essentially so today's column
will be right next to the B column. So if today's date is in H6, C6-G6
would become hidden when one were to open the workbook.

Thanks so much for the insight.
Bo


---
Message posted from http://www.ExcelForum.com/




rickey24[_5_]

Hide Columns
 
Tom

Thanks for the help, but I am getting a 424 error and it i
highlighting the line:

if not res is nothing then

Do you know what this could be?

Thanks

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Hide Columns
 
my bad

should be

if not iserror(res) then

--
Regards,
Tom Ogilvy


"rickey24 " wrote in message
...
Tom

Thanks for the help, but I am getting a 424 error and it is
highlighting the line:

if not res is nothing then

Do you know what this could be?

Thanks.


---
Message posted from http://www.ExcelForum.com/




rickey24[_6_]

Hide Columns
 
Tom

Thanks again for the help, works now. Although I have one las
question. Since I only have weekday dates listed in Row C, If today i
Monday then the formula doesn't work. Is there a way, to say if Date
Monday then ...(Clng(Date - 3) else ...(Clng(Date -1). I am not to
worried about opening it up over the weekend. Thanks again

B

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy[_3_]

Hide Columns
 
Dim idex as Long, res as Variant
Range("C6:IV6").EntireColumn.Hidden = False
idex = choose(Weekday(Date,vbSunday),2,3,1,1,1,1,1)
res = application.Match(clng(Date-idex),Range("C6:IV6"),0)
if not res is nothing then
Range("C6",Range("C6:IV6")(res)).EntireColumn.Hidd en = True
End if

--
Regards,
Tom Ogilv

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 08:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com