Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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
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
Selecting data from another workbook gti_jobert[_50_] Excel Programming 3 March 3rd 06 02:49 PM
Selecting data from 1 workbook to copy and paste to a 2nd workbook JackSpam Excel Programming 2 July 20th 05 02:33 AM
Selecting a worksheet in a workbook Lazer[_8_] Excel Programming 1 August 24th 04 08:52 PM
Selecting workbook Lazer[_6_] Excel Programming 3 August 24th 04 08:12 PM
Selecting the other open workbook Karen[_6_] Excel Programming 2 August 19th 03 05:48 PM


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