Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to Print several worksheets


I am using Excel 2000 SP-3 and Windows XP.

I am recording a macro to print a specific, selected area (say B4:D7)
in All _-Visible-_ Worksheets.
I have 13 Sheets, all with specific names, always the same name, always
in the same order. The first and the last Sheets should
_always_be_excluded_ from being printed.
Any number of the remaining 11 sheets could be hidden, except 3! So I
have always between 3 - 11 sheets to print, never knowing how many or
which one is the last (of the visible) sheets.

I record this operation as follows;
I hide "the First" and "the Last" sheet, I Select the 2nd Sheet (now
the first of the visible sheets), then Select B4:D7, I right click the
sheet tab and choose Select All Sheets and define the print format of
the selection. Then Print and Print selection.
When still having all visible sheets selected I select "A1" (to clean
up all views).
Finally unhide "the First" and "the Last" sheets.
I select "the First" sheet and select "A1", to be at the starting point
again.

When _-Recording-_ this sequence it works perfectly!! I get all visible
worksheets printed, with the choosen format !!

But when _-Running_the_macro-_ I only get the first of the visible
sheets printed!

Can anyone tell me why this happens??

Many thanks in advance
Ulf


--
ulfah
------------------------------------------------------------------------
ulfah's Profile: http://www.excelforum.com/member.php...o&userid=29204
View this thread: http://www.excelforum.com/showthread...hreadid=489381

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro to Print several worksheets

Is it ok to send multiple print jobs?

Option Explicit
Sub testme()
Dim NamesToExclude As Variant
Dim wks As Worksheet
Dim AddrToPrint As String

NamesToExclude = Array("sheet1", "sheet2")
AddrToPrint = "B4:d7"

For Each wks In ThisWorkbook.Worksheets
If wks.Visible = xlSheetVisible Then
If IsNumeric(Application.Match(wks.Name, NamesToExclude, 0)) Then
'skip it
Else
wks.Range(AddrToPrint).PrintOut preview:=True
End If
End If
Next wks

End Sub

ulfah wrote:

I am using Excel 2000 SP-3 and Windows XP.

I am recording a macro to print a specific, selected area (say B4:D7)
in All _-Visible-_ Worksheets.
I have 13 Sheets, all with specific names, always the same name, always
in the same order. The first and the last Sheets should
_always_be_excluded_ from being printed.
Any number of the remaining 11 sheets could be hidden, except 3! So I
have always between 3 - 11 sheets to print, never knowing how many or
which one is the last (of the visible) sheets.

I record this operation as follows;
I hide "the First" and "the Last" sheet, I Select the 2nd Sheet (now
the first of the visible sheets), then Select B4:D7, I right click the
sheet tab and choose Select All Sheets and define the print format of
the selection. Then Print and Print selection.
When still having all visible sheets selected I select "A1" (to clean
up all views).
Finally unhide "the First" and "the Last" sheets.
I select "the First" sheet and select "A1", to be at the starting point
again.

When _-Recording-_ this sequence it works perfectly!! I get all visible
worksheets printed, with the choosen format !!

But when _-Running_the_macro-_ I only get the first of the visible
sheets printed!

Can anyone tell me why this happens??

Many thanks in advance
Ulf

--
ulfah
------------------------------------------------------------------------
ulfah's Profile: http://www.excelforum.com/member.php...o&userid=29204
View this thread: http://www.excelforum.com/showthread...hreadid=489381


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to Print several worksheets


Thanks very much for your help.
That was a very elegant solution, and I made it work!
As you understand I am not very experienced with VB. I usually build my
macros on basis of a recording and from there I try to add on solutions
by trial and error.
As i will try to add Format to your solution as well as different
Ranges and different Layouts.
Thanks again for your support.
Ulf


--
ulfah
------------------------------------------------------------------------
ulfah's Profile: http://www.excelforum.com/member.php...o&userid=29204
View this thread: http://www.excelforum.com/showthread...hreadid=489381

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
I trying to develop a macro to print my worksheets infomercialscams[_2_] Excel Discussion (Misc queries) 1 May 11th 09 01:15 PM
Need to print a workbook but worksheets have diff print areas Angela Steele Excel Discussion (Misc queries) 1 January 17th 08 07:39 PM
Excel 2003: Macro to print areas in mulptiple worksheets Balcott Excel Discussion (Misc queries) 1 December 19th 07 08:34 PM
How do I print a workbook in but only print selected worksheets? Karl S. Excel Discussion (Misc queries) 1 August 31st 06 12:34 AM
I need help makeing a macro to print charts and worksheets WiscGirl Excel Discussion (Misc queries) 0 March 1st 06 04:54 AM


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