Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default HIDING A VARIABLE NUMBER OF COLUMNS

I have a spreadsheet with 12 columns of numbers preceded by one column
with labels. I want to use the same spreadsheet for each month of
data and just hide the blank columns. Since it is February, I want to
hide the columns for March through December (D through M) since they
will be blank. Next month I only want to hide April through December,
etc.

How can I add a dialog box where I enter the number of the month (in
this case 2) and it hides the rest of the months. Or alternatively,
if I tell it how many columns to hide, it can start at column M and
work backwards.

Thanks,



Columns("D:M").Select
Range("D1").Activate
Selection.EntireColumn.Hidden = True

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default HIDING A VARIABLE NUMBER OF COLUMNS

How about something like

Sub HideColumns()

MonthVar = 7

ActiveSheet.Range("B1").Offset(0, MonthVar).Resize(1, 12 -
MonthVar).EntireColumn.Hidden = True


End Sub
I just rezise the range by subtracting the variable from 12 and hide those
columns

Of course you can set an inputbox to the variable or just pull from the
current date

David

" wrote:

I have a spreadsheet with 12 columns of numbers preceded by one column
with labels. I want to use the same spreadsheet for each month of
data and just hide the blank columns. Since it is February, I want to
hide the columns for March through December (D through M) since they
will be blank. Next month I only want to hide April through December,
etc.

How can I add a dialog box where I enter the number of the month (in
this case 2) and it hides the rest of the months. Or alternatively,
if I tell it how many columns to hide, it can start at column M and
work backwards.

Thanks,



Columns("D:M").Select
Range("D1").Activate
Selection.EntireColumn.Hidden = True


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
Adding variable number of columns fabio Excel Worksheet Functions 8 May 23rd 10 07:30 AM
sum number of columns based on variable value rt10516 Excel Discussion (Misc queries) 4 November 8th 07 01:47 PM
adding variable number of columns confused Excel Worksheet Functions 5 September 23rd 05 10:09 AM
Chart based on variable number of columns Scott Hamilton Charts and Charting in Excel 2 June 5th 05 03:36 PM
deleting a variable number of columns Rob Barnard Excel Programming 2 July 28th 03 07:04 PM


All times are GMT +1. The time now is 04:50 AM.

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

About Us

"It's about Microsoft Excel"