Copy table and paste to next empty row

shophoney

Active Member
Joined
Jun 16, 2014
Messages
286
Hi I have a pivot table on sheet 1 and would like to paste values to the next empty row on sheet2.

I need a macro that will select everything but the header on line 1 and grab the data on the table and paste to the next empty line.

Thanks.

This is what i have so far, but it writes over the very last line from the last time i pasted. Also should i turn off screen updating as i will end up with a few million lines over time.





Sub CopyCurrentOH()
Dim ws As Worksheet
Dim rng As Range

Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy

Sheets("OH History").Select
Application.Goto Reference:="R1C1"

Selection.End(xlDown).Select



Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False

Application.Goto Reference:="R1C1"

End Sub
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Code:
[color=darkblue]Sub[/color] CopyCurrentOH()
    
    Range("A2").CurrentRegion.Offset(1).SpecialCells(xlCellTypeVisible).Copy
    
    Sheets("OH History").Select
    Range("A1").End(xlDown).Offset(1).PasteSpecial Paste:=xlPasteValuesAndNumberFormats
    Application.CutCopyMode = [color=darkblue]False[/color]
    
    Application.Goto Reference:="R1C1"
    
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,624
Latest member
gregg777

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