View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Use Array to activate workbooks

Stuart,

For XL2000 onward, where InStrRev exists:

Dim myName As String

For LoopCounter = LBound(FilesArray) to UBound(FilesArray)

myName = FilesArray(LoopCounter)
Workbooks(Mid(myName, InStrRev(myName, "\") + 1)).Activate
'Do other stuff here

Next LoopCounter

HTH,
Bernie
MS Excel MVP

"Stuart" wrote in message
...
The following code works fine, in a situation where the workbooks
are originally opened, worked on, and then closed. FilesArray
holds the names of the previously opened workbooks, and can be
used again to open the books:

If FileCounter 0 Then
Application.ScreenUpdating = False
For LoopCounter = 1 To FileCounter
Workbooks.Open vFilename & FilesArray(LoopCounter), False

In a slightly different situation, the books are still open. Can I

modify
the
code and use FilesArray to activate them in turn?

What I'd like to say, is:
Workbooks.Activate vFilename & FilesArray(LoopCounter),

False
but that is not supported (Excel2000).

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.545 / Virus Database: 339 - Release Date: 27/11/2003