Cut and Insert Rows

Chewyhairball

Active Member
Joined
Nov 30, 2017
Messages
312
Office Version
  1. 365
Platform
  1. Windows
Hi Folks

I have the following bit of code that lets you select a cell from an input box then select a destination cell from another input box. When you click OK it then cuts the selected cell and pastes it to the selected destination.

VBA Code:
Sub movedata()
    Dim FromRange As Range
    Dim ToRange As Range

    Set FromRange = Application.InputBox("Enter the range from which you want to copy : ", Type:=8)
    Set ToRange = Application.InputBox("Enter the range to where you want to copy : ", Type:=8)

    FromRange.Cut ToRange
    

End Sub

What i would actually like it to do is to take the selected cells from the first input box and cut the entire row(or rows) and inset these rows (shift down) to the destination cell row.

eg. In the first input box i might select D20:D23 and the second I might select D30. When i click OK i want the entire rows for 20 to 23 cut and inserted(shift down) to row 30.

thanks in advance for any help with this.

Rory
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
How about
VBA Code:
    FromRange.EntireRow.Cut
    ToRange.EntireRow.Insert
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,516
Messages
6,119,976
Members
448,934
Latest member
audette89

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