Reputation: 43
Good Day,
I have this button that generate unique ID, but before executing that I want a new window that will ask the user how many rows that will add in "A20", then the code for generating ID will execute after adding an specific rows.
Here is the code of generating ID:
Private Sub CommandButton1_Click()
Dim x As String, rcell As Range, y As String, z As Long
x = "RFP" & Format(Now, "mmddyyhhmmss")
y = Left(x, 10)
z = Right(x, 2)
For Each rcell In Range("D20:D" & Range("D" & Rows.Count).End(3).Row)
If Cells(rcell.Row, 4) = "" Then Cells(rcell.Row, 4) = y & z
z = z + 1
Next rcell
End Sub
Thank you in advance any inputs are highly appreciated
Upvotes: 0
Views: 30
Reputation: 5450
Something like this? Not sure what you meant by adding in "A20", I assumed you mean you're adding rows to row 20?
myvalue = Inputbox("How many rows should be added?")
For i = 1 to myvalue
Range("A20").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Next i
Upvotes: 1