VBA Script To Copy & Paste Values & Formatting To First Empty Row

cfcMalky

Board Regular
Joined
Nov 5, 2013
Messages
52
Hi folks, I'm looking for a VBA script that will copy & paste values & formatting to first empty row,
The range I want to copy will contain values generated by formulas but I want to copy and paste them as values & not formulae,
Also I would like to paste the data with formatting into the first blank row starting from a specific row,

Sheet Name: 'Production Log' (Copy Source & Destination Are Both On This Sheet)
Range To Copy: A4:P4 (Values & Formatting Only)
Paste Location: First blank row from row 9 down (A:P)

I will add a button to trigger the script and label the script 'pasteData'

I've had a working script in the past but lost the sheet I had it on and can't find the forum post that I found it on.

Thanks A Bunch In Advance :)
 
Last edited:

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Try this

Code:
Sub copyrow()
    Dim sh As Worksheet, lr As Long
    Application.ScreenUpdating = False
    Set sh = Sheets("Production Log")
    sh.Range("A4:P4").Copy
    lr = sh.Range("A" & Rows.Count).End(xlUp).Row + 1
    If lr < 9 Then lr = 9
    sh.Range("A" & lr).PasteSpecial Paste:=xlPasteValues
    sh.Range("A" & lr).PasteSpecial Paste:=xlPasteFormats
    Range("A4").Select
    Application.CutCopyMode = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,840
Messages
6,121,895
Members
449,058
Latest member
Guy Boot

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