Formula/Code to create a serial number in a new row

STEVENS3010

Board Regular
Joined
Feb 4, 2020
Messages
89
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi all,

Is anybody able to help me figure out how to create a formula or code that could be used to create a sequential serial number in a table of data.

I have a spreadsheet that will be used to log customer enquiries. The sheet has a number of columns of data capture, with the sequential serial numbers in column A. Ideally, I would like to use a macro which will allow me to press a button to generate a new serial number in column A on the next row at the bottom of the data range.

For example, cell A2 would show ref “Prof-Enq0001”. Then when the button is pressed it inserts a new row underneath and automatically inputs “Prof-Enq0002”. If the button is pressed again, the same thing happens and the ref number input below is “Prof-Enq0003”

Is this possible? If so, could somebody point me in the right direction as to how exactly?

Thank you
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
This will do what you require, BUT.. why not simply drag the above row down one by using the fill handle in the bottom right of the cell above ??
VBA Code:
Sub MM1()
Dim lr As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row + 1
Range("A" & lr - 1).AutoFill Destination:=Range("A" & lr - 1 & ":A" & lr), Type:=xlFillDefault
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,029
Messages
6,122,757
Members
449,094
Latest member
dsharae57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top