Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Print sheets based on cell value

I have a workbook of about 30 sheets. Beginning with the 3rd sheet, each
sheet has a date in cell K4. I wish to print just the sheets for which the
month in K4 equals certain values.

So far I have this:

Sub PrintSheets()
Dim MonthDue As Integer
ThisWorkbook.Activate
For Each sh In ThisWorkbook.Sheets
If sh.Index 2 Then
sh.Select 'changing the activesheet
MonthDue = Month(K4)
Select Case MonthDue
Case 4
ActiveSheet.PrintOut
Case 12
ActiveSheet.PrintOut
End Select
End If
Next sh
End Sub

The problem is this: Sheet 3 has a month value of 12 and so prints. The code
cycles to Sheet 4 which has a month value of 5. The variable MonthDue is not
changing though. It's value remains 12 and so prints Sheet 4 though I don't
want it to. What am I missing that would result in MonthDue updating its
value for each sheet?

Thanks for any help.
--
- markvi
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
Printing sheets based on a cell value markvi Excel Programming 1 May 25th 10 05:36 PM
Print page based on the value of a cell Michael Lanier Excel Programming 5 September 25th 09 03:11 PM
Hide sheets based on Cell value Mike Milmoe Excel Discussion (Misc queries) 4 January 16th 07 05:57 AM
Print ranges based on cell value John Excel Programming 1 August 22nd 06 03:41 AM
Open file and print sheets based on data in cell Steph[_6_] Excel Programming 3 August 23rd 05 08:47 PM


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