BennyWhatever
New Member
- Joined
- Sep 18, 2013
- Messages
- 3
Hello,
I've been searching everywhere (particularly on these forums and Microsoft's help site), and I haven't found a solution that has completely worked yet. I'm experienced in Excel but still a little new to VBA.
What I'm trying to do is copy only the cells that have integers in them from range B3:D20 on sheet "Sales", and past them to the row following the last used row in a different sheet "Invoices". Range E3:I20 all use Vlookup so they don't need to be copied over.
I'm currently using this code, but it's pasting over the formatting (which I don't want) and it's not pasting following the last used row - just going over the top of whatever is currently there.
Here is the Sales sheet.

Here's the Invoices sheet.

I've been searching everywhere (particularly on these forums and Microsoft's help site), and I haven't found a solution that has completely worked yet. I'm experienced in Excel but still a little new to VBA.
What I'm trying to do is copy only the cells that have integers in them from range B3:D20 on sheet "Sales", and past them to the row following the last used row in a different sheet "Invoices". Range E3:I20 all use Vlookup so they don't need to be copied over.
I'm currently using this code, but it's pasting over the formatting (which I don't want) and it's not pasting following the last used row - just going over the top of whatever is currently there.
Code:
Private Sub CommandButton5_Click() Dim rng As Range
Set rng = Worksheets("Sales").Range("B3:D20")
rng.Copy
With Worksheets("Invoices")
Dim lr As Long: lr = .Cells(Rows.Count, 1).End(xlUp).Row + 1
.Cells(lr, 2).PasteSpecial xlAll
End With
End Sub
Here is the Sales sheet.

Here's the Invoices sheet.
