Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting Different Workbook
Hello Everyone: I have a workbook called MASTER. MASTER has a macro I need to run in another workbook(wb2) I receive thru email. The problem is that wb2 can have any given name because someone else creates it. With MASTER and wb2 (which can have any name) open, I need a macro that would select and/or make active whichever other workbook is open OTHER THAN MASTER. thanks in advanced, -- halem2 ------------------------------------------------------------------------ halem2's Profile: http://www.excelforum.com/member.php...fo&userid=9930 View this thread: http://www.excelforum.com/showthread...hreadid=535966 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting Different Workbook
IF the macro just updates the data on wb2, then why not simply open the
wb2 file (with Master being already open) then select the macro from the macros list and run it - if it is set up to run on the active workbook, it will run on wb2 as this was active when the macro was called! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting Different Workbook
the macro works fine when wb2 is the active workbook but fails if MASTER is active. I need to have the macro select whicever other workbook is open OTHER than master. That way it will always run on the correct workbook -- halem2 ------------------------------------------------------------------------ halem2's Profile: http://www.excelforum.com/member.php...fo&userid=9930 View this thread: http://www.excelforum.com/showthread...hreadid=535966 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting Different Workbook
You can set up the macro to stop and display a message box if it is ru with the active workbook being "MASTER". Sub Test() If ActiveWorkbook.Name = "MASTER" Then YesNo = MsgBox("Do you want to run on the MASTER workbook?", vbYesNo) If YesNo = vbNo Then MsgBox "Please activate the correct workbook." Exit Sub End If End If 'Your code here End Sub This isn't exactly what you asked for, sorry for that, but it might a least be a temporary fix. -Ikaabo -- Ikaabo ----------------------------------------------------------------------- Ikaabod's Profile: http://www.excelforum.com/member.php...fo&userid=3337 View this thread: http://www.excelforum.com/showthread.php?threadid=53596 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting Different Workbook
thanks for the help...but it still runs in the MASTER wb if it is the one that's active. Your code makes perfect sense but it actually skips the test of Yes No and always runs it. Could it be the wb name? The actual name is Forecast Macro Master.xls. I substitued it in your code but it just fly y without testing it. thanks for your help -- halem2 ------------------------------------------------------------------------ halem2's Profile: http://www.excelforum.com/member.php...fo&userid=9930 View this thread: http://www.excelforum.com/showthread...hreadid=535966 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting Different Workbook
thank you EVERYONE for the help. I got it. This is it. Sub TestNEWW() If ActiveWorkbook.Name < "Forecast Master Macro.xls" Then Macro1 Else: End If End Sub ;) :) -- halem2 ------------------------------------------------------------------------ halem2's Profile: http://www.excelforum.com/member.php...fo&userid=9930 View this thread: http://www.excelforum.com/showthread...hreadid=535966 |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting Different Workbook
Okay, after a little research I found that this should work. Forget my other code and use this to activate another opened workbook that is NOT your Master workbook. This works only if you have 2 workbooks open, the one being the master and the other being the one you want activated. Sub Test() Dim wb As Workbook For Each wb In Application.Workbooks If wb.Name < "Forecast Macro Master" Then wb1 = wb.Name Next wb Workbooks(wb1).Activate End Sub Hope that works for you. -Ikaabod -- Ikaabod ------------------------------------------------------------------------ Ikaabod's Profile: http://www.excelforum.com/member.php...o&userid=33371 View this thread: http://www.excelforum.com/showthread...hreadid=535966 |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting Different Workbook
You will need the exact name for the test to work - try a quick test
subroutine with msgbox activeworkbook.name run it on the master workbook - this will return the name that excel sees. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Selecting data from another workbook | Excel Programming | |||
Selecting data from 1 workbook to copy and paste to a 2nd workbook | Excel Programming | |||
Selecting a worksheet in a workbook | Excel Programming | |||
Selecting workbook | Excel Programming | |||
Selecting the other open workbook | Excel Programming |