Copy row and paste

Shadkng

Active Member
Joined
Oct 11, 2018
Messages
365
Hi, I am trying to copy the active row (based on any selected cell in that row) to a new row number that is entered into the input box. I Any help is appreciated. Thanks

VBA Code:
Sub REMAKE_COPY_LINE()
Dim n As Variant 'Long 'Integer, rng As Range

Selection.EntireRow.Copy

n = InputBox("ENTER ROW TO COPY TO")
    If n = vbNullString Then Exit Sub

End Sub
 
Last edited:

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
VBA Code:
Option Explicit

Sub InsertCopyOfRowBelow()
 Dim rg As Range
 Set rg = Application.InputBox("Select cell where to copy row below : ", , , , , , , 8)
 ActiveCell.EntireRow.Copy
 rg.EntireRow.Insert
 Application.CutCopyMode = False
End Sub

You'll want to add error checking.
 
Upvote 0
VBA Code:
Option Explicit

Sub InsertCopyOfRowBelow()
Dim rg As Range
Set rg = Application.InputBox("Select cell where to copy row below : ", , , , , , , 8)
ActiveCell.EntireRow.Copy
rg.EntireRow.Insert
Application.CutCopyMode = False
End Sub

You'll want to add error checking.
 
Upvote 0
This code seems to be inserting a line. Also I have to specify a cell, but I prefer to specify just a line number in the input box to copy over.
 
Upvote 0
VBA Code:
Option Explicit

Sub InsertCopyOfRowBelow()
  Dim lnRow As Long
  lnRow = InputBox("Enter Row number.", "Row Input")
  ActiveCell.EntireRow.Copy Rows(lnRow & ":" & lnRow)
  Application.CutCopyMode = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,369
Members
449,080
Latest member
Armadillos

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