0

I am trying to insert rows below user input, but my code is kept on adding it above.Can anyone tell me what is going on...

  Dim varUserInput As Variant
  varUserInput = InputBox("Enter Row Number where you want to add a row:", _
  "What Row?")
  If varUserInput = "" Then Exit Sub

  RowNum = varUserInput
  Rows(RowNum & ":" & RowNum).Insert Shift:=xlDown
1

Change xlDown to xlUp, like this:

Dim varUserInput As Variant
  varUserInput = InputBox("Enter Row Number where you want to add a row:", _
  "What Row?")
  If varUserInput = "" Then Exit Sub
  RowNum = varUserInput
  Rows(RowNum & ":" & RowNum).Insert Shift:=xlUp*

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.