Log in

View Full Version : Making a counter go up by 1


Samantha_92
Jun 12, 2008, 11:16 AM
How do I make an Excel Table update every time I use it?

e.g -----> 1 2 3 4 whenever I use it

Any help is appreciated.

JBeaucaire
Jun 12, 2008, 02:26 PM
Try this macro.

Press Alt + F11 > select ThisWorkbook > paste in the code below. Every time you open the file it will increment cell A1 in Sheet 1 (change the reference A1 to whichever cell where you want this to happen)

Excel -- VBA -- Adding Code to a Workbook (http://www.contextures.com/xlvba01.html#Workbook)




Public Sub Workbook_Open()
Dim Rng As Range
Set Rng = ThisWorkbook.Sheets(1).Range("A1")

With Rng
.Value = .Value + 1
End With

End Sub