Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Select for printing

I have some code which produces a list of all the sheets in a Workbook, but I
want to add some user choice on which sheets are printed
ie on a sheet1 (a contents page basically)
COLA COLB
Sheet Name Print
sheet1 N
sheet2 Y
sheet3 N
sheet4 Y
ETC NB growing list of sheets to about 100
They will need to be grouped so page numbering works (1 of 50)

Anybody able to help?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 373
Default Select for printing

This should work. Paste this code in a standard module. James

Sub PrintEm()
Dim k As Long, Ct As Integer
Dim Pg As Integer, BtmRow As Long
Dim ShtNm As String
With ThisWorkbook.Worksheets("Sheet1")
BtmRow = .Cells(.Rows.Count, "a").End(xlUp).Row
Ct = WorksheetFunction.CountIf(Range("b2:b" & BtmRow), "Y")
Pg = 1
For k = 2 To BtmRow
If .Cells(k, "b") = "Y" Then
ShtNm = .Cells(k, "a")
Worksheets(ShtNm).Activate
ActiveSheet.PageSetup.RightFooter = _
"Page " & Pg & " of " & Ct
ActiveSheet.PrintOut
Pg = Pg + 1
End If
Next k
End With
End Sub

"Saintsman" wrote in message
...
I have some code which produces a list of all the sheets in a Workbook, but
I
want to add some user choice on which sheets are printed
ie on a sheet1 (a contents page basically)
COLA COLB
Sheet Name Print
sheet1 N
sheet2 Y
sheet3 N
sheet4 Y
ETC NB growing list of sheets to about 100
They will need to be grouped so page numbering works (1 of 50)

Anybody able to help?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Select for printing

hanks for quick reply...but couldn't make it work
No error message - just nothing happened



"Zone" wrote:

This should work. Paste this code in a standard module. James

Sub PrintEm()
Dim k As Long, Ct As Integer
Dim Pg As Integer, BtmRow As Long
Dim ShtNm As String
With ThisWorkbook.Worksheets("Sheet1")
BtmRow = .Cells(.Rows.Count, "a").End(xlUp).Row
Ct = WorksheetFunction.CountIf(Range("b2:b" & BtmRow), "Y")
Pg = 1
For k = 2 To BtmRow
If .Cells(k, "b") = "Y" Then
ShtNm = .Cells(k, "a")
Worksheets(ShtNm).Activate
ActiveSheet.PageSetup.RightFooter = _
"Page " & Pg & " of " & Ct
ActiveSheet.PrintOut
Pg = Pg + 1
End If
Next k
End With
End Sub

"Saintsman" wrote in message
...
I have some code which produces a list of all the sheets in a Workbook, but
I
want to add some user choice on which sheets are printed
ie on a sheet1 (a contents page basically)
COLA COLB
Sheet Name Print
sheet1 N
sheet2 Y
sheet3 N
sheet4 Y
ETC NB growing list of sheets to about 100
They will need to be grouped so page numbering works (1 of 50)

Anybody able to help?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 373
Default Select for printing

Saintsman, It works fine for me. Did you use copy and paste to put the code
in a STANDARD module and then run it? Try this. Before the line Pg=1, add
this line:
Msgbox BtmRow & " " & Ct
then you can see how many rows there are and how many Y's there are. Let me
know! James

"Saintsman" wrote in message
...
hanks for quick reply...but couldn't make it work
No error message - just nothing happened



"Zone" wrote:

This should work. Paste this code in a standard module. James

Sub PrintEm()
Dim k As Long, Ct As Integer
Dim Pg As Integer, BtmRow As Long
Dim ShtNm As String
With ThisWorkbook.Worksheets("Sheet1")
BtmRow = .Cells(.Rows.Count, "a").End(xlUp).Row
Ct = WorksheetFunction.CountIf(Range("b2:b" & BtmRow), "Y")
Pg = 1
For k = 2 To BtmRow
If .Cells(k, "b") = "Y" Then
ShtNm = .Cells(k, "a")
Worksheets(ShtNm).Activate
ActiveSheet.PageSetup.RightFooter = _
"Page " & Pg & " of " & Ct
ActiveSheet.PrintOut
Pg = Pg + 1
End If
Next k
End With
End Sub

"Saintsman" wrote in message
...
I have some code which produces a list of all the sheets in a Workbook,
but
I
want to add some user choice on which sheets are printed
ie on a sheet1 (a contents page basically)
COLA COLB
Sheet Name Print
sheet1 N
sheet2 Y
sheet3 N
sheet4 Y
ETC NB growing list of sheets to about 100
They will need to be grouped so page numbering works (1 of 50)

Anybody able to help?






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Select for printing

OK that gives me an answer - but then nothing
Question - does this print out individual worksheets?

"Zone" wrote:

Saintsman, It works fine for me. Did you use copy and paste to put the code
in a STANDARD module and then run it? Try this. Before the line Pg=1, add
this line:
Msgbox BtmRow & " " & Ct
then you can see how many rows there are and how many Y's there are. Let me
know! James

"Saintsman" wrote in message
...
hanks for quick reply...but couldn't make it work
No error message - just nothing happened



"Zone" wrote:

This should work. Paste this code in a standard module. James

Sub PrintEm()
Dim k As Long, Ct As Integer
Dim Pg As Integer, BtmRow As Long
Dim ShtNm As String
With ThisWorkbook.Worksheets("Sheet1")
BtmRow = .Cells(.Rows.Count, "a").End(xlUp).Row
Ct = WorksheetFunction.CountIf(Range("b2:b" & BtmRow), "Y")
Pg = 1
For k = 2 To BtmRow
If .Cells(k, "b") = "Y" Then
ShtNm = .Cells(k, "a")
Worksheets(ShtNm).Activate
ActiveSheet.PageSetup.RightFooter = _
"Page " & Pg & " of " & Ct
ActiveSheet.PrintOut
Pg = Pg + 1
End If
Next k
End With
End Sub

"Saintsman" wrote in message
...
I have some code which produces a list of all the sheets in a Workbook,
but
I
want to add some user choice on which sheets are printed
ie on a sheet1 (a contents page basically)
COLA COLB
Sheet Name Print
sheet1 N
sheet2 Y
sheet3 N
sheet4 Y
ETC NB growing list of sheets to about 100
They will need to be grouped so page numbering works (1 of 50)

Anybody able to help?









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Select for printing

OK - FOUND IT - USED CAPITALS IN CODE !! lower case on sheet!
I should know better...Doh!

"Zone" wrote:

Saintsman, It works fine for me. Did you use copy and paste to put the code
in a STANDARD module and then run it? Try this. Before the line Pg=1, add
this line:
Msgbox BtmRow & " " & Ct
then you can see how many rows there are and how many Y's there are. Let me
know! James

"Saintsman" wrote in message
...
hanks for quick reply...but couldn't make it work
No error message - just nothing happened



"Zone" wrote:

This should work. Paste this code in a standard module. James

Sub PrintEm()
Dim k As Long, Ct As Integer
Dim Pg As Integer, BtmRow As Long
Dim ShtNm As String
With ThisWorkbook.Worksheets("Sheet1")
BtmRow = .Cells(.Rows.Count, "a").End(xlUp).Row
Ct = WorksheetFunction.CountIf(Range("b2:b" & BtmRow), "Y")
Pg = 1
For k = 2 To BtmRow
If .Cells(k, "b") = "Y" Then
ShtNm = .Cells(k, "a")
Worksheets(ShtNm).Activate
ActiveSheet.PageSetup.RightFooter = _
"Page " & Pg & " of " & Ct
ActiveSheet.PrintOut
Pg = Pg + 1
End If
Next k
End With
End Sub

"Saintsman" wrote in message
...
I have some code which produces a list of all the sheets in a Workbook,
but
I
want to add some user choice on which sheets are printed
ie on a sheet1 (a contents page basically)
COLA COLB
Sheet Name Print
sheet1 N
sheet2 Y
sheet3 N
sheet4 Y
ETC NB growing list of sheets to about 100
They will need to be grouped so page numbering works (1 of 50)

Anybody able to help?







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 373
Default Select for printing

Saintsman, I've been away for a bit. Going okay now? James

"Saintsman" wrote in message
...
OK - FOUND IT - USED CAPITALS IN CODE !! lower case on sheet!
I should know better...Doh!

"Zone" wrote:

Saintsman, It works fine for me. Did you use copy and paste to put the
code
in a STANDARD module and then run it? Try this. Before the line Pg=1,
add
this line:
Msgbox BtmRow & " " & Ct
then you can see how many rows there are and how many Y's there are. Let
me
know! James

"Saintsman" wrote in message
...
hanks for quick reply...but couldn't make it work
No error message - just nothing happened



"Zone" wrote:

This should work. Paste this code in a standard module. James

Sub PrintEm()
Dim k As Long, Ct As Integer
Dim Pg As Integer, BtmRow As Long
Dim ShtNm As String
With ThisWorkbook.Worksheets("Sheet1")
BtmRow = .Cells(.Rows.Count, "a").End(xlUp).Row
Ct = WorksheetFunction.CountIf(Range("b2:b" & BtmRow), "Y")
Pg = 1
For k = 2 To BtmRow
If .Cells(k, "b") = "Y" Then
ShtNm = .Cells(k, "a")
Worksheets(ShtNm).Activate
ActiveSheet.PageSetup.RightFooter = _
"Page " & Pg & " of " & Ct
ActiveSheet.PrintOut
Pg = Pg + 1
End If
Next k
End With
End Sub

"Saintsman" wrote in message
...
I have some code which produces a list of all the sheets in a
Workbook,
but
I
want to add some user choice on which sheets are printed
ie on a sheet1 (a contents page basically)
COLA COLB
Sheet Name Print
sheet1 N
sheet2 Y
sheet3 N
sheet4 Y
ETC NB growing list of sheets to about 100
They will need to be grouped so page numbering works (1 of 50)

Anybody able to help?









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
Select Printing Macro saltnsnails Excel Discussion (Misc queries) 6 March 13th 08 05:48 PM
Printing select pages zchuckz New Users to Excel 9 December 15th 06 06:51 PM
select sheets for printing bennyob Excel Discussion (Misc queries) 1 November 20th 05 02:52 PM
Printing during select times Rockee052[_28_] Excel Programming 1 February 6th 04 08:35 PM
Printing Only Select Columns Bill Martin Excel Programming 1 July 31st 03 04:56 PM


All times are GMT +1. The time now is 05:31 PM.

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"