Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Printing Worksheets thru VBA

Hi all,
I'm creating a UserForm, and I'm trying to code a command button that
will print a sheet from another workbook.

I'm wondering though, what code can I add so that if cell A1 has data
in it, it will print sheet1 of the other workbook.

If A2 has data in it, it will print sheet2 of the other workbook, but
not sheet1, despite the fact that A1 has data in it.

If A3 has data in it, it will print sheet3 of the other workbook, but
not sheet1 or sheet2 despite the fact that they have data in them. and
so on...

In a nutshell, I just want to print the corresponding sheet in the
other workbook for the last cell of data only in column A...if that
makes sense.

Thanks in Advance for all your help.


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Printing Worksheets thru VBA

Something like this

If Activesheet.Range("A3") < "" Then
Worksheets(3).Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
ElseIf Activesheet.Range("A2") < "" Then
Worksheets(2).Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
ElseIf Activesheet.Range("A1") < "" Then
Worksheets(1).Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"abxy " wrote in message
...
Hi all,
I'm creating a UserForm, and I'm trying to code a command button that
will print a sheet from another workbook.

I'm wondering though, what code can I add so that if cell A1 has data
in it, it will print sheet1 of the other workbook.

If A2 has data in it, it will print sheet2 of the other workbook, but
not sheet1, despite the fact that A1 has data in it.

If A3 has data in it, it will print sheet3 of the other workbook, but
not sheet1 or sheet2 despite the fact that they have data in them. and
so on...

In a nutshell, I just want to print the corresponding sheet in the
other workbook for the last cell of data only in column A...if that
makes sense.

Thanks in Advance for all your help.


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Printing Worksheets thru VBA

Thanks a lot, just looking at the code, I think this will work, after
modify it for my particular situation of course, but anyhoo, I just go
off work and i'm a bit tired, i'll try this out as soon as I get in th
morning. I'll post again on this thread to let you know my results.
can't thankyou enough. I don't think i would have ever thought o
anything in that manner...i'm a newbie to VBA, i'm slowly grasping i
though.

In the meantime, if anyone else has any alternative suggestions o
anything of the sort, let me know.

Thanks again Bob Phillips! :

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Printing Worksheets thru VBA

Modified the code a bit to satisfy my particular situation, and it work
great! Thanks a lot Bob Phillips. I couldn't have done it without you
help!

Thanks a lot mate! :

--
Message posted from http://www.ExcelForum.com

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 worksheets Emma_D[_2_] Excel Discussion (Misc queries) 0 February 12th 09 04:26 PM
Printing Most but not all worksheets JeffH Excel Discussion (Misc queries) 1 August 1st 07 09:45 PM
Printing several worksheets at once koobro Excel Discussion (Misc queries) 2 March 6th 07 12:19 AM
printing worksheets Graham7979 Excel Discussion (Misc queries) 1 May 29th 06 09:12 PM
Printing worksheets Karen Excel Discussion (Misc queries) 3 April 23rd 05 10:40 PM


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