Macro: Coding Macro to Select, Cut and Paste Row from one sheet to another (Excel 2010)

Sppinner

New Member
Joined
May 6, 2013
Messages
20
Hello! I am needing to code a macro that can select a row of information, cut it and then paste it into a different (already labeled) sheet. To elaborate I would like to select cut the information from "Sheet 1" and then paste it into "Sheet 2" in an identical format without pasting over any rows that are already present. To give an example, I would like to select and cut the following row: [TABLE="width: 500"]
<tbody>[TR]
[TD]Name
[/TD]
[TD]Address
[/TD]
[TD]Phone Number
[/TD]
[TD]Male/Female
[/TD]
[/TR]
[TR]
[TD]Simpson, OJ
[/TD]
[TD]123 Glove Fit Road
[/TD]
[TD](110) 495-4830
[/TD]
[TD]Male
[/TD]
[/TR]
</tbody>[/TABLE]
And then paste it into a different sheet so that it looks like this:[TABLE="width: 500"]
<tbody>[TR]
[TD]Name
[/TD]
[TD]Address
[/TD]
[TD]Phone Number
[/TD]
[TD]Male/Female
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Winehouse, Amy
[/TD]
[TD]423 Rehab Cres.
[/TD]
[TD](375) 836-8463
[/TD]
[TD]Female
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Brown, James
[/TD]
[TD]395 Feel Good Way
[/TD]
[TD](576) 846-3976
[/TD]
[TD]Male
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Bonds, Barry
[/TD]
[TD]923 Roid and Run Street
[/TD]
[TD](458) 747-4856
[/TD]
[TD]Male
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Simpson, OJ
[/TD]
[TD]123 Glove Fit Road
[/TD]
[TD](566) 846-4854
[/TD]
[TD]Male
[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
hi and welcome to Mr Excel Board
something like below ( it will cut activerow and paste to sheet 2 )
Code:
Sub Test()
ActiveCell.EntireRow.Cut Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
End Sub
 
Upvote 0
Thanks Keva! It worked perfectly! In regards to your code, I understand what most of it is saying but I am a bit unsure about what the "End.(x1Up) and Offset (1,0)" functions actually mean. Would you be ok with elaborating them for me? I'm new to Macros and am trying to learn as much as I can!
 
Upvote 0
"End(Xlup)" means Range("A" & Rows.Count) = A and how many rows in excel sheet suppose its 2007 and later 1048576 so Range("A1048576") select and from that to go up and when found and nonblank cell then stop so suppose nonblank cell is A11 so it will select A11 but i want to paste data in A12(next blank cell) so offset (1,0) means that select row A12 if you put there offset(2,0) it will select A13

if you want to learn more then make one test workbook and make changes in code and see what happen thats better to learn

Hope you understand this
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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