incrementing field number

mona4

Board Regular
Joined
Sep 15, 2004
Messages
191
Hi,

Is there a way that every time you open a spreadsheet the field number on the sheet increments a bit like a counter?

Thanks
Mona
 

Some videos you may like

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Hi Mona

You could use a bit of code to increment a value in a cell - is this what you meant?

Code would look something like this (needs to go into ThisWorkbook module):

Code:
Private Sub Workbook_Open()
Sheets("YourSheetName").Range("A1").Value = Sheets("YourSheetName").Range("A1").Value + 1
End Sub

Best regards

Richard
 

mona4

Board Regular
Joined
Sep 15, 2004
Messages
191
Yes i think so but would this be able to increment each time the spreadsheet form opens.

I have a purchase order form in excel. This is what the customer uses. Each order is a row on the form. Once they confirm the order by pressing a command button i want all the rows to display on another spreadsheet form which i use.

Is this possible?
 

mona4

Board Regular
Joined
Sep 15, 2004
Messages
191
I am really confused....

I used the above code to increment the sheet. It wont give me the option to assign the code to the text box. I am also confused that i cannot even see the number on the sheet where it increments.
 

mona4

Board Regular
Joined
Sep 15, 2004
Messages
191

ADVERTISEMENT

Ok i can see the number displayed when i run the code. I wouldl like this displayed in a text box?
 

mona4

Board Regular
Joined
Sep 15, 2004
Messages
191
Ok i can see the number displayed when i run the code. I wouldl like this displayed in a text box?
 

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707

ADVERTISEMENT

Hi

What code are you running with at the moment, and where is your text box?

Richard
 

mona4

Board Regular
Joined
Sep 15, 2004
Messages
191
This is the code in ThisWorkbook:

Private Sub Workbook_Open()
Sheet1.Range("J4") = Sheet1.Range("J4") + 1
End Sub

I am trying to display it in cell J4 in a TextBox. When i run it, it displays the create a macro dialog box. Dont know why.
 

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
OK. How have you created this textbox? Is it from the Control Toolbox and inserted on your worksheet?
 

mona4

Board Regular
Joined
Sep 15, 2004
Messages
191
Yes i inserted the box then right clicked to assign the macro but no luck
 

Watch MrExcel Video

Forum statistics

Threads
1,114,402
Messages
5,547,748
Members
410,810
Latest member
thepinkbird
Top