LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Run macro from active workbook whose name keeps changing

Have a look at...

GetOpenFilename()

...and 'Set' a fully qualified ref to it. For example...


Sub Backup()
Dim wkbSource As Workbook, wkbTarget As Workbook, sFilename$

sFilename = Get_FileToOpen("Excel Files ""*.xlsb"", (*.xls)")
If sFilename = "" Then Exit Sub '//user cancels

Set wkbSource = Workbooks("Iron Horse MBC Listing 0.3.0.xlsb")
Set wkbTarget = Workbooks.Open(Filename:=sFilename)

wkbTarget.Range("A9:N20000") = wkbSource.Range("A9:N20000")
wkbTarget.Close SaveChanges:=True

wkbSource.Sheets("Cover").Select
End Sub


Function Get_FileToOpen$(Optional FileTypes$)
If FileTypes = "" Then FileTypes = "All Files ""*.*"", (*.*)"
Get_FileToOpen = Application.GetOpenFilename(FileTypes)
End Function

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


 
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
Macro that opens a separate workbook to a specified worksheet whenthe active workbook is right mouse clicked Michael Lanier Excel Programming 8 December 20th 11 09:51 PM
Call macro from active workbook John[_140_] Excel Programming 4 October 3rd 09 04:07 AM
Run Macro on all WS in active workbook.. jeremiah Excel Programming 6 May 6th 08 05:56 PM
Changing the active workbook SP[_5_] Excel Programming 6 October 16th 05 10:36 PM
run a macro on an in-active workbook jfeka[_2_] Excel Programming 4 July 19th 03 03:49 PM


All times are GMT +1. The time now is 12:39 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"