Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Print Excel worksheet several times, looping value of 1 cell

I need to print a worksheet several times, using the value of 1 cell as an
automatic loop-counter from 1 to, say, 10.
1. Can it be done without a macro?
2. If not, what is the VBA code for a suitable macro? (I have a lot of
programming experience, but hardly any VBA!)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Print Excel worksheet several times, looping value of 1 cell

Manual there is no option for this

For code see this page to print the activesheet
http://www.rondebruin.nl/print.htm#number

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Hershmab" wrote in message ...
I need to print a worksheet several times, using the value of 1 cell as an
automatic loop-counter from 1 to, say, 10.
1. Can it be done without a macro?
2. If not, what is the VBA code for a suitable macro? (I have a lot of
programming experience, but hardly any VBA!)

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Print Excel worksheet several times, looping value of 1 cell

Sorry, I left out some critical information so that both replies, yours and
"Mike"'s, do not solve my problem:
The whole of the worksheet consists of formulae dependent on the value of
the "looping" cell.
So the cell must change its value and the worksheet must be recalculated
every time before it is printed.
The loop will always start at 1, but the maximum will vary from time to
time. I could put the current maximum into another cell in the worksheet

"Ron de Bruin" wrote:

Manual there is no option for this

For code see this page to print the activesheet
http://www.rondebruin.nl/print.htm#number

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Hershmab" wrote in message ...
I need to print a worksheet several times, using the value of 1 cell as an
automatic loop-counter from 1 to, say, 10.
1. Can it be done without a macro?
2. If not, what is the VBA code for a suitable macro? (I have a lot of
programming experience, but hardly any VBA!)


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Print Excel worksheet several times, looping value of 1 cell

You can try this

It change the value of A1 ten times and print (1-10)

Sub test()
Dim num As Long

For num = 1 To 10
With ActiveSheet

.Range("a1").Value = num

.Calculate

'Print the sheet
.PrintOut
End With
Next num

End Sub



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Hershmab" wrote in message ...
Sorry, I left out some critical information so that both replies, yours and
"Mike"'s, do not solve my problem:
The whole of the worksheet consists of formulae dependent on the value of
the "looping" cell.
So the cell must change its value and the worksheet must be recalculated
every time before it is printed.
The loop will always start at 1, but the maximum will vary from time to
time. I could put the current maximum into another cell in the worksheet

"Ron de Bruin" wrote:

Manual there is no option for this

For code see this page to print the activesheet
http://www.rondebruin.nl/print.htm#number

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Hershmab" wrote in message ...
I need to print a worksheet several times, using the value of 1 cell as an
automatic loop-counter from 1 to, say, 10.
1. Can it be done without a macro?
2. If not, what is the VBA code for a suitable macro? (I have a lot of
programming experience, but hardly any VBA!)


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Print Excel worksheet several times, looping value of 1 cell

On Jul 14, 9:17 am, "Ron de Bruin" wrote:
You can try this

It change the value of A1 ten times and print (1-10)

Sub test()
Dim num As Long

For num = 1 To 10
With ActiveSheet

.Range("a1").Value = num

.Calculate

'Print the sheet
.PrintOut
End With
Next num

End Sub

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm

"Hershmab" wrote in ...
Sorry, I left out some critical information so that both replies, yours and
"Mike"'s, do not solve my problem:
The whole of the worksheet consists of formulae dependent on the value of
the "looping" cell.
So the cell must change its value and the worksheet must be recalculated
every time before it is printed.
The loop will always start at 1, but the maximum will vary from time to
time. I could put the current maximum into another cell in the worksheet


"Ron de Bruin" wrote:


Manual there is no option for this


For code see this page to print the activesheet
http://www.rondebruin.nl/print.htm#number


--


Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Hershmab" wrote in ...
I need to print a worksheet several times, using the value of 1 cell as an
automatic loop-counter from 1 to, say, 10.
1. Can it be done without a macro?
2. If not, what is the VBA code for a suitable macro? (I have a lot of
programming experience, but hardly any VBA!)


To make it flexible to print the number of times you specify in a cell
(say B1), you need to pull the value of B1 in as a variable, which is
simply

Dim nloops as Long
nloops = Range("B1").Value

For num = 1 to nloops
..
..
..

When I move variables on or off the spreadsheet I prefer to define and
use named ranges. Name A1 "Target" and B1 "NumLoops" for example, and
use:

Range("Target").Value = num

and

nloops = Range("NumLoops").Value





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Print Excel worksheet several times, looping value of 1 cell

Sub printCopies()
Dim myCell As String

myCell = Range("A1").Value
ActiveWindow.SelectedSheets.PrintOut _
Copies:=myCell, Collate:=True
End Sub

"Hershmab" wrote:

I need to print a worksheet several times, using the value of 1 cell as an
automatic loop-counter from 1 to, say, 10.
1. Can it be done without a macro?
2. If not, what is the VBA code for a suitable macro? (I have a lot of
programming experience, but hardly any VBA!)

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Print Excel worksheet several times, looping value of 1 cell

Thanks to all three of you who replied, so helpfully. I have one more
question about this topic:

At the moment Excel sends each report/copy to the printer individually;
is there any way to send them all together as a single multi-sheet printout?

"Mike" wrote:

Sub printCopies()
Dim myCell As String

myCell = Range("A1").Value
ActiveWindow.SelectedSheets.PrintOut _
Copies:=myCell, Collate:=True
End Sub

"Hershmab" wrote:

I need to print a worksheet several times, using the value of 1 cell as an
automatic loop-counter from 1 to, say, 10.
1. Can it be done without a macro?
2. If not, what is the VBA code for a suitable macro? (I have a lot of
programming experience, but hardly any VBA!)

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
Print same Excel sheet several times but while changing footer? rlipp Excel Discussion (Misc queries) 1 September 6th 06 08:39 PM
history of dates/times an excel worksheet was opened? Randy Excel Discussion (Misc queries) 0 July 18th 06 09:19 PM
Looping a macro x times(x being activecell.value)? [email protected] Excel Programming 4 July 7th 06 08:08 AM
Print a worksheet when a cell = 1 Pat Excel Discussion (Misc queries) 3 December 8th 05 02:45 PM
Excel opening a "phantom" worksheet at random times lbfries Excel Discussion (Misc queries) 0 October 6th 05 06:06 PM


All times are GMT +1. The time now is 12:31 AM.

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"