Paste selection minus the first row....

R

RompStar

Hi there,

I have code that copies from a sheet to a new sheet in a different
workbook. It's doing appends onto the same sheet. For the first
paste I want to paste everything, but for the second paste, I want to
paste everything minus the first row, which is a header row. In the
Else how do I tell VBA to ActiveSheet.Paste (-1) ????

This If-Then-Else

If lastrow2 = 1 Then
ActiveSheet.Paste
Else
real = lastrow2 + 1
Range("A" & real).Select
ActiveSheet.Paste
End If

Thanks for the help.
 
D

Dave Peterson

You'll have to change the range that should be copied. Just avoid that topmost
row.


With RngToCopy
set rngtocopy = .resize(.rows.count-1).offset(1,0)
end with

This may even work???
 
N

Norman Jones

Hi RompStar,

I am not sure what your code is doing.

However, as example of a method of
returning a range without its header row,
try something like

'=========>>
Public Sub Tester()
Dim Rng As Range
Dim Rng2 As Range

Set Rng = Range("A1:D10")

With Rng
Set Rng2 = .Offset(1).Resize(.Rows.Count - 1)
End With

MsgBox Rng2.Address(0, 0)

End Sub
'<<=========
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top