#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 42
Default Macros

I have 2 workbooks wich require the same data to be entered into them each
month (Each workbook has a different end purpose). In the past I have tried
linking the 2 workbooks by formula but because the workbooks are obiviously
saved in 2 different places, the links sometimes for one reason or another
break. I was wondering if there was any way a macro could be written on one
workbook that would place the data in the relevant worksheet tab & cells of
the other one or would this be too complicated?!

--
Lois
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9,101
Default Macros

This is done all the time. it is simple to open one workbook from antoher
and move the data.

Below is a very simple case of one workbook opening another and copying some
data

You can record a macro while performing the operations and then re-use the
macro when you need to perform the operations again. I would reecommend
editing the recorded macro when you get done because the recorder creates a
lot of extra statements that aren't required. I can reduce the recorder
macro when you get done.

Sub test()

Set BK1 = ThisWorkbook
Set Bk1Sht = BK1.Sheets("Sheet1")
BookName = "c:\temp\book1.xls"
Set Bk2 = Workbooks.Open(Filename:=BookName)
Set Bk2Sht = Bk2.Sheets("Sheet1")

With BK1
BK1Sht.Range("A1") = Bk2Sht.Range("C4")

BkSht2.Range("B7:D10").Copy _
Destination:=Bk1Sht.Range("B9")

End With

Bk2.clise savechanges:=False

End Sub



"Lois" wrote:

I have 2 workbooks wich require the same data to be entered into them each
month (Each workbook has a different end purpose). In the past I have tried
linking the 2 workbooks by formula but because the workbooks are obiviously
saved in 2 different places, the links sometimes for one reason or another
break. I was wondering if there was any way a macro could be written on one
workbook that would place the data in the relevant worksheet tab & cells of
the other one or would this be too complicated?!

--
Lois

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 42
Default Macros

Thanks, i will try this & see if i can get it to work!
will let you know
--
Lois


"joel" wrote:

This is done all the time. it is simple to open one workbook from antoher
and move the data.

Below is a very simple case of one workbook opening another and copying some
data

You can record a macro while performing the operations and then re-use the
macro when you need to perform the operations again. I would reecommend
editing the recorded macro when you get done because the recorder creates a
lot of extra statements that aren't required. I can reduce the recorder
macro when you get done.

Sub test()

Set BK1 = ThisWorkbook
Set Bk1Sht = BK1.Sheets("Sheet1")
BookName = "c:\temp\book1.xls"
Set Bk2 = Workbooks.Open(Filename:=BookName)
Set Bk2Sht = Bk2.Sheets("Sheet1")

With BK1
BK1Sht.Range("A1") = Bk2Sht.Range("C4")

BkSht2.Range("B7:D10").Copy _
Destination:=Bk1Sht.Range("B9")

End With

Bk2.clise savechanges:=False

End Sub



"Lois" wrote:

I have 2 workbooks wich require the same data to be entered into them each
month (Each workbook has a different end purpose). In the past I have tried
linking the 2 workbooks by formula but because the workbooks are obiviously
saved in 2 different places, the links sometimes for one reason or another
break. I was wondering if there was any way a macro could be written on one
workbook that would place the data in the relevant worksheet tab & cells of
the other one or would this be too complicated?!

--
Lois

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macros: can you copy macros from one doc to another? Roady Excel Discussion (Misc queries) 1 June 12th 08 05:47 PM
Excel 2007 macros - how to merge 5 macros together into one Sue Excel Discussion (Misc queries) 1 April 16th 08 08:36 PM
Macros warning always shows up, even if all macros removed Joe M Excel Discussion (Misc queries) 1 December 20th 07 04:45 AM
Macros - copying macros from one computer to another TT Excel Discussion (Misc queries) 18 December 14th 06 03:24 AM
Training: More on how to use macros in Excel: Recording Macros ToriT Excel Worksheet Functions 2 February 10th 06 07:05 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"