View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ben McClave Ben McClave is offline
external usenet poster
 
Posts: 173
Default Loop through named workbooks

Hi Keri,

This code should work. It should be relatively easy to adjust this as necessary.

Ben

Sub Books()
Dim wbk(1 To 3) As Workbook
Dim x As Long
Dim strMessage As String

'Change the wbk's below to whatever workbooks you need.
Set wbk(1) = ThisWorkbook
Set wbk(2) = ActiveWorkbook
Set wbk(3) = Workbooks("Book1")

strMessage = "Your workbook names a" & vbCr & vbCr

For x = 1 To 3
strMessage = strMessage & wbk(x).Name & vbCr
With wbk(x)
'perform whatever you need to on the workbooks
End With
Next x

MsgBox strMessage

End Sub