Newbie VBA Questions - Print Loop, Incrementing Serial Nos.

Alriemer

Board Regular
Joined
Aug 18, 2002
Messages
102
Hello all,

I appologize for the basic nature of this question but didn't turn up much that I understoop in search of the board or VBA Help.

Task at hand: automatically print set of cash receipts with serial numbers, given number of copies to print; save and close worksheet.

Sheet1 consists of 4 cash receipts (2 printable pages) with serial numbers - say 001 through 004. Macro should get next serial number (005 - calulated in a cell named New_Serial_No) and put it in a cell named First_Serial_No; calculate and print; repeat until completing a given number of copies (value entered in cell named Number_To_Print); save and close.

Here is code - crashes when executed with error "Object doesn't support this property or method".
===================

Dim Counter As Integer
Dim Number_To_Print As Integer
Dim New_Serial_No As Integer
Dim MyCell As Range

Private Sub PrintLoop()
MyCell = ActiveSheet.ActiveCell
Number_To_Print = Range("Sheet1!Number_To_Print").Value
Counter = 0
Do
With Worksheets("Sheet1")
New_Serial_No = .Range("New_Serial_No").Value
.Range("First_Serial_No") = New_Serial_No
.Calculate
.Print
Counter = Counter + 1
End With
Loop While Counter < Number_To_Print

Range(MyCell).Select
ActiveWorkbook.Save
ActiveWorkbook.Close

End Sub
===============

Any suggestions/corrections much appreciated.
Regards,
alriemer
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Re: Newbie VBA Questions - Print Loop, Incrementing Serial N

Thanks guys, that worked great.

Cheers
alriemer
 
Upvote 0

Forum statistics

Threads
1,221,691
Messages
6,161,322
Members
451,696
Latest member
Senthil Murugan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top