increment/populate numbers by worksheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to populate cell A1 in each worksheet in my workbook with a number
that increments by one every sheet. So A1 value in first worksheet would be
1; in second worksheet, 2 etc.

How?
 
br

This code was originally written to increase a date in A1 across sheets.

Have re-written to increase a number across sheets. Left in the date
parts(commented) in case you ever wanted to use that.

Sub Date_Increment()
''increment a date in A1 across sheets
Dim myDate As Long 'Date
Dim iCtr As Long
myDate = 1 'DateSerial(2004, 4, 19)
For iCtr = 1 To Worksheets.Count
With Worksheets(iCtr).Range("A1")
.Value = myDate - 1 + iCtr
.NumberFormat = 0 ' "mm/dd/yyyy"
End With
Next iCtr
End Sub


Gord Dibben Excel MVP
 
If your sheets are the default XL names (Sheet1, Sheet2, ... etc.)
OR
You care to name them in such a way that the last character in the sheet
name is the "page" number, you could simply use this formula in A1 of each
sheet:

=RIGHT(CELL("filename",A1))
--

HTH,

RD
==============================================
Please keep all correspondence within the Group, so all may benefit!
==============================================


I want to populate cell A1 in each worksheet in my workbook with a number
that increments by one every sheet. So A1 value in first worksheet would be
1; in second worksheet, 2 etc.

How?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top