ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA to count rows in a sheet and increase counter on another sheet then print (https://www.excelbanter.com/excel-programming/353722-vba-count-rows-sheet-increase-counter-another-sheet-then-print.html)

lgj32

VBA to count rows in a sheet and increase counter on another sheet then print
 
I have a dataset which could have a variable number of rows on a sheet
called "Data", on the first sheet I have a template which shows all the
data for that record and in cell A1 the record number (starts at 1).

I need the Template sheet number to increase by one each time, print
then increase the number and print gain until it reaches the end of the
records on the "data" sheet.

At the moment I am manually typing in the record number and printing,
but there must be a simplier way by using VBA to automate this. I
haven't used macros for years and years so am very rusty can anybody
help?

Thanks


Bob Phillips[_6_]

VBA to count rows in a sheet and increase counter on another sheet then print
 
Is this because you just want the row number of copies, if so why not just
use

Dim iLastRow As Long
iLastRow = Worksheets("data").End(xlUp).Row
Worksheets("data").PrintOut copies:=iLastRow


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"lgj32" wrote in message
oups.com...
I have a dataset which could have a variable number of rows on a sheet
called "Data", on the first sheet I have a template which shows all the
data for that record and in cell A1 the record number (starts at 1).

I need the Template sheet number to increase by one each time, print
then increase the number and print gain until it reaches the end of the
records on the "data" sheet.

At the moment I am manually typing in the record number and printing,
but there must be a simplier way by using VBA to automate this. I
haven't used macros for years and years so am very rusty can anybody
help?

Thanks





All times are GMT +1. The time now is 04:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com