0

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

1 Answer 1

1

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

Before&After

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for the inputs but I want only the cell A20 where to add the new cell not the entire A20..B20..C20.. sorry if my question is confusing..
@N323100 Fixed it to just add new cells at A20, try it now -

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.