Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Adding a new row with a macro
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? -- -Mike |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Adding a new row with a macro
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 -- HTH... Jim Thomlinson "Dobbs734" wrote: 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? -- -Mike |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Adding a new row with a macro
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. -- -Mike "Jim Thomlinson" wrote: 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 -- HTH... Jim Thomlinson "Dobbs734" wrote: 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? -- -Mike |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Adding to a Macro | Excel Discussion (Misc queries) | |||
Adding code to a macro | Excel Worksheet Functions | |||
Macro for adding more sheets | Excel Discussion (Misc queries) | |||
Adding a Tab in a Macro | Excel Discussion (Misc queries) | |||
Adding Row to this macro | Excel Discussion (Misc queries) |