ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy From One WorkbookTo Another (https://www.excelbanter.com/excel-programming/349715-copy-one-workbookto-another.html)

Lilbit

Copy From One WorkbookTo Another
 
I recorded a macro that copies cells from one workbook(the name never
changes) to another workbook(the name changes each time a report is
generated), but I realized the name of the report/workbook is in the
macro. How do I change the name to indicate that it is to paste it into
whatever report I'm working on or is there a macro that does away with
this problem? Thanks!!


Martin Fishlock[_3_]

Copy From One WorkbookTo Another
 
Dear Lilbit:

You can try using a a custom form, inputboxs, calling the macro from the
sheet it is to be copies to or use cells in worksheet to record the workbook
and worksheet.

The easiest is the call the macro from the sheet that the cells are to be
copies to:
' copy cell A1 on sheet 1 from the fixed workbook FROM.XLS to the active
sheet.
sub copycell()
activesheet.range("A1") = workbook("FROM.XLS").worksheets("Sheet
1").range("A1)
end sub

I leave the other methods for your inverstigation.


--
HTHs Martin


"Lilbit" wrote:

I recorded a macro that copies cells from one workbook(the name never
changes) to another workbook(the name changes each time a report is
generated), but I realized the name of the report/workbook is in the
macro. How do I change the name to indicate that it is to paste it into
whatever report I'm working on or is there a macro that does away with
this problem? Thanks!!



evgny[_2_]

Copy From One WorkbookTo Another
 
Hi Lilbit
Play with this, you can use
Application.ScreenUpdating = False/true
Dim wsName As String
wsName = InputBox(Prompt:="Paste to workbook", Title:="workbook name",
Default:="")
Workbooks(wsName).Worksheets(1).Activate

or use copy, destination:=Workbooks(wsName).Worksheets(1).range ("A1")

Regards
Yngve


Lilbit

Copy From One WorkbookTo Another
 
Thanks very very much!!



All times are GMT +1. The time now is 12:45 PM.

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