ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Append data in a separate spreadsheet using a Macro (https://www.excelbanter.com/excel-programming/323808-append-data-separate-spreadsheet-using-macro.html)

Hadesandjodi

Append data in a separate spreadsheet using a Macro
 
First of all I am a macro newbie so please be gentle with me if you are kind
enough to respond.

I have 5 cells of data in a spreadsheet that I want to copy to a separate
spreadsheet, appending the existing data table. Can this be done with a macro?

Jim Thomlinson[_3_]

Append data in a separate spreadsheet using a Macro
 
Yes this is very possible, but it is a little tricky for a beginner. If you
would like to attempt it then you need to give a bit more info. What event
will trigger the transfer form one book to the other (button click?,
spreadsheet close?, cell value change?). Is it always the same 5 cells to be
copied. What are the book names and what are the sheet names. Is the
destination book going to be open already or does the code need to open the
book. Should the book be closed when the code finishes.

Try recording a macro to do this and take a look at the code that is
generated. Re-run the macro and see what happens. Then get back to us with
some more specific questions...

HTH

"Hadesandjodi" wrote:

First of all I am a macro newbie so please be gentle with me if you are kind
enough to respond.

I have 5 cells of data in a spreadsheet that I want to copy to a separate
spreadsheet, appending the existing data table. Can this be done with a macro?


Hadesandjodi

Append data in a separate spreadsheet using a Macro
 
OK, I have recorded a macro. The problem is I don't know how to do the append
part, so when it runs it just keeps recording to the same static cell that I
originally selected.

I'll answer some of the questions you've posed and also include the code of
the macro that doesn't quite work (does everything but append!)

What event will trigger the transfer form one book to the other (button click?,
spreadsheet close?, cell value change?).

Cell value change. But it's changed already in a previous macro so its just
ready to be copied.

Is it always the same 5 cells to be copied.

Yes

What are the book names and what are the sheet names.

You can see it in the macro code I 've pasted below

Is the destination book going to be open already or does the code need to open the book.

Needs to open the book, but that part of the macro already works.

Should the book be closed when the code finishes.

Not needed.

Macro code:
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 2/22/2005 by tvshoj
'

'
ChDir "R:\Production\SAP\Inventory Reports"
Workbooks.Open Filename:= _
"R:\Production\SAP\Inventory Reports\Inventory Levels - Actual by
Day.xls"
Sheets("Count").Select
Range("B6").Select
ActiveCell.FormulaR1C1 = "=NOW()"
Range("C6").Select
Windows("Warehouse Macro Template.xls").Activate
Sheets("Summary").Select
Range("C8:C13").Select
Selection.Copy
Windows("Inventory Levels - Actual by Day.xls").Activate
Range("C6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=True
Sheets("Weight").Select
Range("B6").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=NOW()"
Range("C6").Select
Windows("Warehouse Macro Template.xls").Activate
Range("F8:F13").Select
Selection.Copy
Windows("Inventory Levels - Actual by Day.xls").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=True
Application.CutCopyMode = False
Range("B7").Select
ActiveWorkbook.Save
Windows("Warehouse Macro Template.xls").Activate
Range("B16").Select
End Sub




All times are GMT +1. The time now is 02:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com