Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Hide/Unhide Columns representing dates as per Current System Date!

Hi,

If i have 31 columns having 31 days ( in mm/dd/yy format - made into text) &
i want to hide the columns showing current date - 1 & i also want to hide
the columns showing current date1( i.e. before midnight), & just show the
column showing current date as Visible, how do i do that on opening the
workbook? Also, since i am working night shifts, after 12:00 midnight ,there
should be 2 columns available that is the previous current date column for
some time say till next 12 hours & the new column which became visible only
after midnight.

How is it possible using VBA?

Rgds,

Eijaz






  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Hide/Unhide Columns representing dates as per Current System Date!

Elijaz,

Here's some workbook open code

Private Sub Workbook_Open()
Dim iDay As Long
With Worksheets("Sheet1")
.Columns("A:AE").Hidden = True
iDay = Day(Date)
.Columns(iDay).Hidden = False
If Hour(Now) < 12 And iDay 1 Then
.Columns(iDay - 1).Hidden = False
End If
End With

End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"gr8guy" wrote in message
...
Hi,

If i have 31 columns having 31 days ( in mm/dd/yy format - made into text)

&
i want to hide the columns showing current date - 1 & i also want to hide
the columns showing current date1( i.e. before midnight), & just show the
column showing current date as Visible, how do i do that on opening the
workbook? Also, since i am working night shifts, after 12:00 midnight

,there
should be 2 columns available that is the previous current date column for
some time say till next 12 hours & the new column which became visible

only
after midnight.

How is it possible using VBA?

Rgds,

Eijaz








  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Hide/Unhide Columns representing dates as per Current System Date!

Thanks Bob,

Works Perfect! Exactly what i needed!
wanted to ask you one thing though! If there are checkboxes (using forms
toollbar) in the hidden columns, would they be visible completely or the
last column AE checkboxes will be visible on column AF, which i dont want to
happen.

how to avoid this using code i.e. how to Hide the Checkboxes along with
their respective columns & make only current day checkboxes visible as per
your code?

Rgds,

Eijaz



"Bob Phillips" wrote in message
...
Elijaz,

Here's some workbook open code

Private Sub Workbook_Open()
Dim iDay As Long
With Worksheets("Sheet1")
.Columns("A:AE").Hidden = True
iDay = Day(Date)
.Columns(iDay).Hidden = False
If Hour(Now) < 12 And iDay 1 Then
.Columns(iDay - 1).Hidden = False
End If
End With

End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"gr8guy" wrote in message
...
Hi,

If i have 31 columns having 31 days ( in mm/dd/yy format - made into

text)
&
i want to hide the columns showing current date - 1 & i also want to

hide
the columns showing current date1( i.e. before midnight), & just show

the
column showing current date as Visible, how do i do that on opening the
workbook? Also, since i am working night shifts, after 12:00 midnight

,there
should be 2 columns available that is the previous current date column

for
some time say till next 12 hours & the new column which became visible

only
after midnight.

How is it possible using VBA?

Rgds,

Eijaz










  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Hide/Unhide Columns representing dates as per Current System Date!

Elijaz,

Assuming you are using checkboxes form the control toolbox, you can hide
them with

ActiveSheet.OLEObjects("Checkbox1").Visible = False

and show them with

ActiveSheet.OLEObjects("Checkbox1").Visible = True

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"gr8guy" wrote in message
...
Thanks Bob,

Works Perfect! Exactly what i needed!
wanted to ask you one thing though! If there are checkboxes (using forms
toollbar) in the hidden columns, would they be visible completely or the
last column AE checkboxes will be visible on column AF, which i dont want

to
happen.

how to avoid this using code i.e. how to Hide the Checkboxes along with
their respective columns & make only current day checkboxes visible as per
your code?

Rgds,

Eijaz



"Bob Phillips" wrote in message
...
Elijaz,

Here's some workbook open code

Private Sub Workbook_Open()
Dim iDay As Long
With Worksheets("Sheet1")
.Columns("A:AE").Hidden = True
iDay = Day(Date)
.Columns(iDay).Hidden = False
If Hour(Now) < 12 And iDay 1 Then
.Columns(iDay - 1).Hidden = False
End If
End With

End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"gr8guy" wrote in message
...
Hi,

If i have 31 columns having 31 days ( in mm/dd/yy format - made into

text)
&
i want to hide the columns showing current date - 1 & i also want to

hide
the columns showing current date1( i.e. before midnight), & just show

the
column showing current date as Visible, how do i do that on opening

the
workbook? Also, since i am working night shifts, after 12:00 midnight

,there
should be 2 columns available that is the previous current date column

for
some time say till next 12 hours & the new column which became visible

only
after midnight.

How is it possible using VBA?

Rgds,

Eijaz












Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How Unhide & Hide Columns with VBA jean Excel Discussion (Misc queries) 1 June 17th 09 02:03 AM
Hide / Unhide columns for Printing Ripper Excel Discussion (Misc queries) 1 April 16th 08 10:43 PM
Hide/Unhide columns using button on top over relevant columns [email protected] Excel Discussion (Misc queries) 1 March 7th 07 09:24 PM
Unhide and hide columns [email protected] Excel Worksheet Functions 1 October 23rd 06 07:16 PM
system variable representing subroutine name? Bob Kilmer Excel Programming 0 July 9th 03 12:30 AM


All times are GMT +1. The time now is 06:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"