Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Other Open Workbook

Hi...

I have 10 files...1 file will remain open at all times(Master)...Then I open
the other 9 files 1 at a time...

Is there anyway that when the Master file is the one activated, how would I
tell VBA to select the other file without knowing it's name?

Any help is greatly apprecited and thank you for your time.

t
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Other Open Workbook

Here's one way:

Sub Test()
Dim i As Long
Dim Here As Workbook, There As Workbook
Set Here = ThisWorkbook
Set There = Nothing
If Workbooks.Count < 2 Then Exit Sub
For i = 1 To Workbooks.Count
If Workbooks(i).FullName < Here.FullName Then
Set There = Workbooks(i)
There.Activate
MsgBox There.FullName
Here.Activate
MsgBox "Back"
End If
Next
End Sub

HTH. Best wishes Harald

"MrHappy" skrev i melding
...
Hi...

I have 10 files...1 file will remain open at all times(Master)...Then I

open
the other 9 files 1 at a time...

Is there anyway that when the Master file is the one activated, how would

I
tell VBA to select the other file without knowing it's name?

Any help is greatly apprecited and thank you for your time.

t



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Other Open Workbook

Harald,

Thank you! That was very interesting!!!

Here and There! Thats good :)

Thank you for your time and support, truly appreciated.

Tim




"Harald Staff" wrote:

Here's one way:

Sub Test()
Dim i As Long
Dim Here As Workbook, There As Workbook
Set Here = ThisWorkbook
Set There = Nothing
If Workbooks.Count < 2 Then Exit Sub
For i = 1 To Workbooks.Count
If Workbooks(i).FullName < Here.FullName Then
Set There = Workbooks(i)
There.Activate
MsgBox There.FullName
Here.Activate
MsgBox "Back"
End If
Next
End Sub

HTH. Best wishes Harald

"MrHappy" skrev i melding
...
Hi...

I have 10 files...1 file will remain open at all times(Master)...Then I

open
the other 9 files 1 at a time...

Is there anyway that when the Master file is the one activated, how would

I
tell VBA to select the other file without knowing it's name?

Any help is greatly apprecited and thank you for your time.

t




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Other Open Workbook

Probably should adjust this code to ignore workbooks that are not visible,
such as personal.xls.

--
Regards,
Tom Ogilvy

"MrHappy" wrote in message
...
Harald,

Thank you! That was very interesting!!!

Here and There! Thats good :)

Thank you for your time and support, truly appreciated.

Tim




"Harald Staff" wrote:

Here's one way:

Sub Test()
Dim i As Long
Dim Here As Workbook, There As Workbook
Set Here = ThisWorkbook
Set There = Nothing
If Workbooks.Count < 2 Then Exit Sub
For i = 1 To Workbooks.Count
If Workbooks(i).FullName < Here.FullName Then
Set There = Workbooks(i)
There.Activate
MsgBox There.FullName
Here.Activate
MsgBox "Back"
End If
Next
End Sub

HTH. Best wishes Harald

"MrHappy" skrev i melding
...
Hi...

I have 10 files...1 file will remain open at all times(Master)...Then

I
open
the other 9 files 1 at a time...

Is there anyway that when the Master file is the one activated, how

would
I
tell VBA to select the other file without knowing it's name?

Any help is greatly apprecited and thank you for your time.

t






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Other Open Workbook

Harald,

I have used code similar to this in an application, but one line is causing
a Dr.Watson error when I try and refer to a sheet:

Here.Activate
Sheets("My Sheet").Select <== This line causes the error.
'Range("A2").Select <== With the line above and these
'ActiveSheet.Paste <== lines commented out, the
MsgBox ("Data Pasted") <== MsgBox command works.

etc etc

Am I trying to refer to "My Sheet" in the wrong syntax please?

Thanks,
Ewan



"Harald Staff" wrote:

Here's one way:

Sub Test()
Dim i As Long
Dim Here As Workbook, There As Workbook
Set Here = ThisWorkbook
Set There = Nothing
If Workbooks.Count < 2 Then Exit Sub
For i = 1 To Workbooks.Count
If Workbooks(i).FullName < Here.FullName Then
Set There = Workbooks(i)
There.Activate
MsgBox There.FullName
Here.Activate
MsgBox "Back"
End If
Next
End Sub

HTH. Best wishes Harald

"MrHappy" skrev i melding
...
Hi...

I have 10 files...1 file will remain open at all times(Master)...Then I

open
the other 9 files 1 at a time...

Is there anyway that when the Master file is the one activated, how would

I
tell VBA to select the other file without knowing it's name?

Any help is greatly apprecited and thank you for your time.

t






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
How to: Open closed workbook/Search data tables/Return data to open workbook Hugh Adams Excel Discussion (Misc queries) 0 August 18th 10 02:04 PM
Opening Excel, Book1 opens, remains open with other workbook open DanieB Excel Discussion (Misc queries) 0 September 3rd 09 08:23 AM
how do i open a data workbook when i open a timesheet workbook [email protected] uk Excel Discussion (Misc queries) 2 January 4th 09 04:50 PM
excel 2003 saved file will not open without a blank workbook open Bob Excel Discussion (Misc queries) 4 November 11th 06 04:24 PM
How do you program so that Workbook B cannot be open unless Workbook A is open? Plus I need to validation Marcello do Guzman[_3_] Excel Programming 2 December 5th 04 06:50 AM


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