Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Use one Macro on multiple workbooks

I have a number of workbooks, each containing a database with identical sheet
layouts. I want to use a single macro to copy a group of formulas from one
workbook (Formulas.xls) that will copy to and then run against any of the
databases (ex. 090918.xls).
I have written a macro that works (test 4), but it only works on one database.
Is there a way to have the macro select €œActiveWorkbook€ instead of the
specific workbook I used when I wrote the macro? See underlined example
below:

' Test4 Macro
' Macro recorded 3/9/2009 by Ralph Forbes
'
' Keyboard Shortcut: Ctrl+z
'
Windows("Formulas.XLS").Activate
Range("L15:Q17").Select
Selection.Copy
Windows("090918.xls").Activate
ActiveSheet.Paste
Range("L17:Q17").Select
Application.CutCopyMode = False

Thank you,
Ralph Forbes

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default Use one Macro on multiple workbooks

Something like:

Dim ws as Worksheet
set ws = activeworkbook
Windows("Formulas.XLS").Range("L15:Q17").Copy
ws.range("L15:q17").paste


Should work - I've free typed that so you may have to tweak the syntax.

"RSForbes" wrote:

I have a number of workbooks, each containing a database with identical sheet
layouts. I want to use a single macro to copy a group of formulas from one
workbook (Formulas.xls) that will copy to and then run against any of the
databases (ex. 090918.xls).
I have written a macro that works (test 4), but it only works on one database.
Is there a way to have the macro select €œActiveWorkbook€ instead of the
specific workbook I used when I wrote the macro? See underlined example
below:

' Test4 Macro
' Macro recorded 3/9/2009 by Ralph Forbes
'
' Keyboard Shortcut: Ctrl+z
'
Windows("Formulas.XLS").Activate
Range("L15:Q17").Select
Selection.Copy
Windows("090918.xls").Activate
ActiveSheet.Paste
Range("L17:Q17").Select
Application.CutCopyMode = False

Thank you,
Ralph Forbes

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Use one Macro on multiple workbooks

With Workbooks("Formulas.XLS")

.Range("L15:Q17").Copy
Activeworkbook.ActiveSheet.Range("L17:Q17").Paste
End With

--
__________________________________
HTH

Bob

"RSForbes" wrote in message
...
I have a number of workbooks, each containing a database with identical
sheet
layouts. I want to use a single macro to copy a group of formulas from
one
workbook (Formulas.xls) that will copy to and then run against any of the
databases (ex. 090918.xls).
I have written a macro that works (test 4), but it only works on one
database.
Is there a way to have the macro select "ActiveWorkbook" instead of the
specific workbook I used when I wrote the macro? See underlined example
below:

' Test4 Macro
' Macro recorded 3/9/2009 by Ralph Forbes
'
' Keyboard Shortcut: Ctrl+z
'
Windows("Formulas.XLS").Activate
Range("L15:Q17").Select
Selection.Copy
Windows("090918.xls").Activate
ActiveSheet.Paste
Range("L17:Q17").Select
Application.CutCopyMode = False

Thank you,
Ralph Forbes



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
Multiple Workbooks using same macro Bing59 Excel Discussion (Misc queries) 4 January 24th 10 03:38 AM
Need Help Creating a Macro Multiple Workbooks to One Howeecow Excel Worksheet Functions 1 June 7th 07 06:20 PM
macro: copy multiple workbooks to multiple tabs in single book Michael Excel Programming 0 July 14th 06 04:53 PM
Running the same macro to multiple workbooks Raman325[_11_] Excel Programming 0 July 1st 05 04:48 PM
Accessing multiple workbooks through a macro Raman325 Excel Programming 6 June 29th 05 05:28 PM


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

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

About Us

"It's about Microsoft Excel"