Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Marco de Witte
 
Posts: n/a
Default printing an array of worksheets

I have an excel-file with a lot of worksheets in it, and I would like to
print only a few of them (in my case: from the first sheet to a sheet named
"btw").

I have the following code (selection made manually):

Sub TestPrint()
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("Voorblad").Select
Sheets(Array("Voorblad", "Inhoudsopgave", "Opdracht", "res", "fin",
"liq", "balans", _
"V&W", "kosten", "Grondslagen", "vaste_act", "fin_act", "vl_act",
"liq midd", "ev", _
"pass lang", "pass kort", "btw")).Select
Sheets("Voorblad").Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub

But if there's a worksheet added, it will not be in the array.

And I have another code, selecting everything from the first sheet to the
sheet "btw", but it doesn't print the page-numbering allright (and with the
first code is does that allright):

Sub PrintenJaarrapport()

Dim S As Worksheet

For Each S In Worksheets
S.Select
If S.Name = "rekenblad" Then
Exit Sub
End If
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
'Selection.PrintOut Copies:=1, Collate:=True
'ActiveWindow.SelectedSheets.PrintPreview
Next S
Worksheets("Inhoudsopgave").Activate

End Sub


Is there someone who can help me with this problem?

Thanks, Marco.
  #2   Report Post  
Bernie Deitrick
 
Posts: n/a
Default

Marco,

Sub TestPrint2()
Dim i As Integer
For i = Sheets("Voorblad").Index To Sheets("btw").Index
Sheets(i).Select False
Next i
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub

HTH,
Bernie
MS Excel MVP

"Marco de Witte" wrote in message
...
I have an excel-file with a lot of worksheets in it, and I would like to
print only a few of them (in my case: from the first sheet to a sheet

named
"btw").

I have the following code (selection made manually):

Sub TestPrint()
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("Voorblad").Select
Sheets(Array("Voorblad", "Inhoudsopgave", "Opdracht", "res", "fin",
"liq", "balans", _
"V&W", "kosten", "Grondslagen", "vaste_act", "fin_act", "vl_act",
"liq midd", "ev", _
"pass lang", "pass kort", "btw")).Select
Sheets("Voorblad").Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub

But if there's a worksheet added, it will not be in the array.

And I have another code, selecting everything from the first sheet to the
sheet "btw", but it doesn't print the page-numbering allright (and with

the
first code is does that allright):

Sub PrintenJaarrapport()

Dim S As Worksheet

For Each S In Worksheets
S.Select
If S.Name = "rekenblad" Then
Exit Sub
End If
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
'Selection.PrintOut Copies:=1, Collate:=True
'ActiveWindow.SelectedSheets.PrintPreview
Next S
Worksheets("Inhoudsopgave").Activate

End Sub


Is there someone who can help me with this problem?

Thanks, Marco.



  #3   Report Post  
Marco de Witte
 
Posts: n/a
Default

Hello Bernie,

it works perfect, when my cursor-position is on one of the sheets that has
to be selected. When the cursor is on one of the sheets that has not to be
printed, it adds that sheet also. Any idea how I can fix that?

Greetings, Marco.

"Bernie Deitrick" wrote:

Marco,

Sub TestPrint2()
Dim i As Integer
For i = Sheets("Voorblad").Index To Sheets("btw").Index
Sheets(i).Select False
Next i
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub

HTH,
Bernie
MS Excel MVP

"Marco de Witte" wrote in message
...
I have an excel-file with a lot of worksheets in it, and I would like to
print only a few of them (in my case: from the first sheet to a sheet

named
"btw").

I have the following code (selection made manually):

Sub TestPrint()
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("Voorblad").Select
Sheets(Array("Voorblad", "Inhoudsopgave", "Opdracht", "res", "fin",
"liq", "balans", _
"V&W", "kosten", "Grondslagen", "vaste_act", "fin_act", "vl_act",
"liq midd", "ev", _
"pass lang", "pass kort", "btw")).Select
Sheets("Voorblad").Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub

But if there's a worksheet added, it will not be in the array.

And I have another code, selecting everything from the first sheet to the
sheet "btw", but it doesn't print the page-numbering allright (and with

the
first code is does that allright):

Sub PrintenJaarrapport()

Dim S As Worksheet

For Each S In Worksheets
S.Select
If S.Name = "rekenblad" Then
Exit Sub
End If
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
'Selection.PrintOut Copies:=1, Collate:=True
'ActiveWindow.SelectedSheets.PrintPreview
Next S
Worksheets("Inhoudsopgave").Activate

End Sub


Is there someone who can help me with this problem?

Thanks, Marco.




  #4   Report Post  
Bernie Deitrick
 
Posts: n/a
Default

Marco,

Add the line:

Sheets("Voorblad").Select

just after

Dim i As Integer

HTH,
Bernie
MS Excel MVP

"Marco de Witte" wrote in message
...
Hello Bernie,

it works perfect, when my cursor-position is on one of the sheets that has
to be selected. When the cursor is on one of the sheets that has not to be
printed, it adds that sheet also. Any idea how I can fix that?

Greetings, Marco.

"Bernie Deitrick" wrote:

Marco,

Sub TestPrint2()
Dim i As Integer
For i = Sheets("Voorblad").Index To Sheets("btw").Index
Sheets(i).Select False
Next i
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub

HTH,
Bernie
MS Excel MVP

"Marco de Witte" wrote in

message
...
I have an excel-file with a lot of worksheets in it, and I would like

to
print only a few of them (in my case: from the first sheet to a sheet

named
"btw").

I have the following code (selection made manually):

Sub TestPrint()
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("Voorblad").Select
Sheets(Array("Voorblad", "Inhoudsopgave", "Opdracht", "res",

"fin",
"liq", "balans", _
"V&W", "kosten", "Grondslagen", "vaste_act", "fin_act",

"vl_act",
"liq midd", "ev", _
"pass lang", "pass kort", "btw")).Select
Sheets("Voorblad").Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub

But if there's a worksheet added, it will not be in the array.

And I have another code, selecting everything from the first sheet to

the
sheet "btw", but it doesn't print the page-numbering allright (and

with
the
first code is does that allright):

Sub PrintenJaarrapport()

Dim S As Worksheet

For Each S In Worksheets
S.Select
If S.Name = "rekenblad" Then
Exit Sub
End If
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
'Selection.PrintOut Copies:=1, Collate:=True
'ActiveWindow.SelectedSheets.PrintPreview
Next S
Worksheets("Inhoudsopgave").Activate

End Sub


Is there someone who can help me with this problem?

Thanks, Marco.






  #5   Report Post  
Marco de Witte
 
Posts: n/a
Default

It works, thanks!

"Bernie Deitrick" wrote:

Marco,

Add the line:

Sheets("Voorblad").Select

just after

Dim i As Integer

HTH,
Bernie
MS Excel MVP

"Marco de Witte" wrote in message
...
Hello Bernie,

it works perfect, when my cursor-position is on one of the sheets that has
to be selected. When the cursor is on one of the sheets that has not to be
printed, it adds that sheet also. Any idea how I can fix that?

Greetings, Marco.

"Bernie Deitrick" wrote:

Marco,

Sub TestPrint2()
Dim i As Integer
For i = Sheets("Voorblad").Index To Sheets("btw").Index
Sheets(i).Select False
Next i
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub

HTH,
Bernie
MS Excel MVP

"Marco de Witte" wrote in

message
...
I have an excel-file with a lot of worksheets in it, and I would like

to
print only a few of them (in my case: from the first sheet to a sheet
named
"btw").

I have the following code (selection made manually):

Sub TestPrint()
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("Voorblad").Select
Sheets(Array("Voorblad", "Inhoudsopgave", "Opdracht", "res",

"fin",
"liq", "balans", _
"V&W", "kosten", "Grondslagen", "vaste_act", "fin_act",

"vl_act",
"liq midd", "ev", _
"pass lang", "pass kort", "btw")).Select
Sheets("Voorblad").Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub

But if there's a worksheet added, it will not be in the array.

And I have another code, selecting everything from the first sheet to

the
sheet "btw", but it doesn't print the page-numbering allright (and

with
the
first code is does that allright):

Sub PrintenJaarrapport()

Dim S As Worksheet

For Each S In Worksheets
S.Select
If S.Name = "rekenblad" Then
Exit Sub
End If
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
'Selection.PrintOut Copies:=1, Collate:=True
'ActiveWindow.SelectedSheets.PrintPreview
Next S
Worksheets("Inhoudsopgave").Activate

End Sub


Is there someone who can help me with this problem?

Thanks, Marco.






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
data entry on multiple worksheets diosdias Excel Discussion (Misc queries) 1 December 7th 04 05:33 PM
Linked worksheets John Kelly Excel Discussion (Misc queries) 1 December 2nd 04 12:36 AM
VBA Import of text file & Array parsing of that data Dennis Excel Discussion (Misc queries) 4 November 28th 04 10:20 PM
Assigning Cells in worksheets to other data in other worksheets. David McRitchie Excel Discussion (Misc queries) 0 November 27th 04 06:15 PM
Enable Double sided printing contiuously when printing multiple s. Lee Excel Discussion (Misc queries) 1 November 27th 04 01:58 AM


All times are GMT +1. The time now is 12:20 PM.

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"