Question
August 24, 2007 at 06:55 AM
stewart54

Programming Command buttons in Excel

by stewart54 . Updated 19 years, 2 months ago

The “Test” code below works as written, but to prevent overwriting currently used areas of the sheet, it was written with the current target cell at “A5000”

The target or “Pasted-to range” needs be the next available row in a records stack that starts at a501, then A502 for the next record; and so-on.

Here is the Code as written:

Private Sub CommandButton3_Click()
Worksheets(“les”).Activate
Range(“Ac3:aC24”).Select
Range(“Ac3:aC24”).Copy
Range(“a5000”).PasteSpecial xlPasteValuesAndNumberFormats, SkipBlanks:=False, Transpose:=True
Worksheets(“les”).Activate
Range(“af1”).Select
Range(“ac4”).Select
End Sub

The expression in question is:

*** Range(“a5000”).PasteSpecial xlPasteValuesAndNumberFormats, SkipBlanks:=False, Transpose:=True ***

How can this code be written in order for it to look for the next open row to paste the copied range?

Any help with this is greatly appreciated…

This discussion is locked

All Comments