Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Hide the current month columns

I am creating a monthly forecast sheet. There are columns P to Z listed
as forecast columns with the MOnths ( Jan to Dec).
Cell A1 in the sheet is the currrent month cell which changes every
month.

I want the sheet ot hide the current month column. Suppose if A1= Jan,
then column "P( Jan ) " should hide itself. Similarly if the current
month A1= June then the columns "P to U" should hide.

I would greatly appreciate if someone cold help me with this problem.

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Hide the current month columns


iCol = Application.Match(A1,Range("P1:Z1"),0)
Columns("P:P").Resize(iCol-15).Hidden = True

This assumes that A1 has the month name string, not a date,a s does P1:Z1,
and that all months are in that range.
--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

wrote in message
oups.com...
I am creating a monthly forecast sheet. There are columns P to Z listed
as forecast columns with the MOnths ( Jan to Dec).
Cell A1 in the sheet is the currrent month cell which changes every
month.

I want the sheet ot hide the current month column. Suppose if A1= Jan,
then column "P( Jan ) " should hide itself. Similarly if the current
month A1= June then the columns "P to U" should hide.

I would greatly appreciate if someone cold help me with this problem.

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Hide the current month columns

Thanks Bob,
I tried to use this but its giving me error. and not working. Is there
any other way to do achieve the results.

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Hide the current month columns

Sorry, here is a correction

iCol = Application.Match(Range("A1"), Range("P1:Z1"), 0)
Columns("P:P").Resize(iCol).Hidden = True


--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

wrote in message
oups.com...
Thanks Bob,
I tried to use this but its giving me error. and not working. Is there
any other way to do achieve the results.

Thanks



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Hide the current month columns

Bob It gives me the following error

Run Time error 1004
Application defined or object defined error.


I m not good in macros.If there is something missing that i m not
adding then please let me know.

thanks again



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Hide the current month columns


Hi you can try this, the first lot of code gets pasted into the cod
sheet for sheet1 (assuming this is where you want to do the business
and the next lot can just go in a module of its own, it worked for me
When you activate the sheet it will hide the column that has the heade
matching A1 when you close the work book it will un hide all column
ready for the next time you open it, i'm sure there are better ways o
achieving this but this should get you started.

Simon

Private Sub Worksheet_Activate()
Dim Rng As Range
Dim mycell
With Sheets("Sheet1")
Set Rng = Range("P1:Z1")
For Each mycell In Rng
If mycell.Text = Range("A1").Text Then
mycell.EntireColumn.Select
Selection.EntireColumn.Hidden = True
End If
Next mycell
End With
End Sub

Sub Auto_Close()
Cells.Select
Selection.EntireColumn.Hidden = False
End Su

--
Simon Lloy
-----------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...nfo&userid=670
View this thread: http://www.excelforum.com/showthread.php?threadid=51751

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Hide the current month columns

Thanks Simon,
I tried to use the Macro , but it hides all the columns from C to Z. I
could not understand why? Can you guide me more in this problem.

Thanks

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Hide the current month columns

It only works from P to Z. It will have no effect on columns before P
unless you have Merged cells. Do you have merged cells in your sheet?

--
Regards,
Tom Ogilvy


wrote in message
oups.com...
Thanks Simon,
I tried to use the Macro , but it hides all the columns from C to Z. I
could not understand why? Can you guide me more in this problem.

Thanks



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Hide the current month columns

Thanks ....Yes I had a first rwo as merged cells. Its working now.
Thanks sooooo much.

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Hide the current month columns

Thanks Simon,
I tried to use the Macro , but it hides all the columns from C to Z. I
could not understand why? Can you guide me more in this problem.

Thanks



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
Subtract a future month from the current month to get remaining m. Fletch Excel Worksheet Functions 1 July 26th 07 04:29 PM
Retrieve data for previous 3, 6, 12 month given current month GB Excel Worksheet Functions 4 July 19th 07 11:58 PM
copy worksheet from previous month and rename to current month Dan E. Excel Programming 4 December 8th 05 09:40 PM
Calculate the first day of the month for the current month? April S. Excel Discussion (Misc queries) 5 July 27th 05 08:53 PM
Hide/Unhide Columns representing dates as per Current System Date! gr8guy Excel Programming 3 June 13th 04 10:11 AM


All times are GMT +1. The time now is 05:34 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"