abcde123483
abcde123483

Reputation: 3905

Excel VBA: Printing x copies each with an increasing number in a cell

Is it possible to either:

I know this is a very basic question, but bear with me - It is the 1st time I'm trying my luck at Excel macros.

Cheers

Upvotes: 0

Views: 5541

Answers (2)

Robert Mearns
Robert Mearns

Reputation: 11996

This code can be put into 'ThisWorkbook' object to increment a cell value each time something from the workbook is printed.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
 ThisWorkbook.Sheets("Sheet1").Range("A1").Value = _
  ThisWorkbook.Sheets("Sheet1").Range("A1").Value + 1
End Sub

Upvotes: 3

positivesigner
positivesigner

Reputation: 168

It is possible to use a VBA Macro to populate and print a worksheet. For Excel 2010, use the Developer ribbon to Record Macro. It will record the steps you want in a Visual Basic macro, which you can then edit. You can change the macro to use a For-loop, changing the worksheet each time before you print.

Upvotes: 1

Related Questions