Adding a new row with a macro

D

Dobbs734

Hi,

This may be a relatively simple question, but I'm having some trouble with
the programing behind it...

What I want to do is to use a macro to copy data from one one sheet to
another. Once the data is copied onto the other sheet, the next time you use
the macro, it would automatically make a new row of data instead of
overwriting the existing row. How would I do that?
 
J

Jim Thomlinson

Here is some generic code to do what you have asked. Note that the
destination is determined by coming up from the bottom of Column A to the
first populated cell and moving down one row from there.

Sub test()
Sheets("Sheet1").Range("A1:E1").Copy _
Destination:=Sheets("Sheet2").Cells(Rows.Count,
"A").End(xlUp).Offset(1, 0)
End Sub
 
D

Dobbs734

Thanks Jim,

Although, this did not solve my problem I understand the generic code you
gave me. Specifically what I need is column of data to be copied onto
another sheet where it will be transposed on a row. Then, as I stated before,
to add a new row eachtime that macro is used.

I changed the "sheets" names to the ones I used and changed the "A1:E1" to
the fields I want copied. The error occurs with the "A" after the "Count"
entry, which reads:

"Compile Error: Expected: line number or label or statement or end of
statement"

Any idea of what may be happening?

Thanks again.
 

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