Paste cell range below specific named cell(s)

nathanzumbaugh

New Member
Joined
Jan 7, 2009
Messages
9
Would love to paste a range of cells from one sheet to another sheet, but have the qualifier to be the first row available below a named cell.
Here is the code that works well to just paste it to the sheet, but i need to specify where it goes.
-----
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim copySheet As Worksheet
Dim pasteSheet As Worksheet

Set copySheet = Worksheets("Sheet4")
Set pasteSheet = Worksheets("Sheet3")

copySheet.Range("a3:l3").Copy
pasteSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues


Application.CutCopyMode = True
Application.ScreenUpdating = True

End Sub
-----

Want to be able to click the button to make it paste to the first row below cells named "work" as seen in the screenshot.
1715631040545.png


1715631119767.png
 

Attachments

  • 1715631017714.png
    1715631017714.png
    45.9 KB · Views: 6

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Tweak the line to:
VBA Code:
pasteSheet.Range("work").Offset(1, 0).PasteSpecial xlPasteValues
 
Upvote 0
Tweak the line to:
VBA Code:
pasteSheet.Range("work").Offset(1, 0).PasteSpecial xlPasteValues
Holy crap! Thanks!

What about making the values that get copied to "clear out" once the button is clicked. Then i know it has been copied to the other sheet?
the clear contents syntax doesn't work with the "PasteSpecial xLPasteValues" being on the end...
Let me know.
Thanks again.
 
Upvote 0
And, need another tweak to enable me to make multiple command buttons to add multiple ranges of data to populate below the "work" cell without overwriting the single row it populates.

This doesnt work...
 
Upvote 0
# Post#3:
After the PasteSpecial line add:
VBA Code:
copySheet.Range("A3:L3").ClearContents

# Post#4:
Could be a solution:
Code:
'...
copySheet.Range("A3:L3").Copy
If pasteSheet.Range("work").Offset(1, 0) <> "" Then
    pasteSheet.Range("work").End(xlDown).Offset(1, 0).PasteSpecial xlPasteValues
Else
    pasteSheet.Range("work").Offset(1, 0).PasteSpecial xlPasteValues
End If
copySheet.Range("A3:L3").ClearContents
'...
but this has nothing to do with the topic of this thread.
 
Upvote 0
Solution
Thanks you Rollis. I know its not specific to the thread title. Its been a long time since ive hit any forums. Thank you again for your patience.
NZ
 
Upvote 0
Thanks for the feedback(y), glad having been of some help.
By the way, if so, you probably need to mark this thread as [Solved].
 
Upvote 0

Forum statistics

Threads
1,223,445
Messages
6,172,176
Members
452,446
Latest member
walkman99

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