Copying selected cells from one sheet 1 to an empty row in sheet 2

Ashp94

New Member
Joined
May 13, 2020
Messages
4
Office Version
  1. 365
Platform
  1. Windows
I'm trying to figure out the code for copying selected cells from one sheet to an empty row in another sheet, this is what I have so far, but I cannot figure out how to make it so that it copys in next empty row, rather than replacing whats there

Range("A24:G24").Select
Selection.Copy
Sheets("Master Data").Select
Range("A5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub

So I want the code to find the next empty row after A5, even if it gets to a50. I know this is possible as a previous spreadsheet of mine did that, but it's been a few years and I've forgotten, and no longer have that spreadsheet
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
How about:
Change sheet1 to the name of the source sheet

VBA Code:
Sub test()
  Sheets("Master Data").Range("A" & Rows.Count).End(3)(2).Resize(1, 7).Value = Sheets("Sheet1").Range("A24:G24").Value
End Sub
 
Upvote 0
How about:
Change sheet1 to the name of the source sheet

VBA Code:
Sub test()
  Sheets("Master Data").Range("A" & Rows.Count).End(3)(2).Resize(1, 7).Value = Sheets("Sheet1").Range("A24:G24").Value
End Sub
Hey, nah that's not working for me
 
Upvote 0
What doesn't work?
Send you an error?
Don't want to put the name of the sheet "Sheet1"?

If you are going to run the macro on the source sheet then just use this:

VBA Code:
Sub test()
  Sheets("Master Data").Range("A" & Rows.Count).End(3)(2).Resize(1, 7).Value = Range("A24:G24").Value
End Sub
 
Upvote 0
Th
What doesn't work?
Send you an error?
Don't want to put the name of the sheet "Sheet1"?

If you are going to run the macro on the source sheet then just use this:

VBA Code:
Sub test()
  Sheets("Master Data").Range("A" & Rows.Count).End(3)(2).Resize(1, 7).Value = Range("A24:G24").Value
End Sub

That's working for me now, thank you so much!!!!
 
Upvote 0
You are welcome, thanks for the feedback.
Hey, sorry to be a pain. but for some reason despite working perfectly before now, an error of "Compile error expected end sub" is showing but I can't see why, any ideas?
 
Upvote 0
Is any line in the macro highlighted? what is that line
Check that the macro is complete, maybe some letter was deleted.
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,214
Members
449,074
Latest member
cancansova

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