Lizz45ie,
Depending on what you are trying to do with your macro you may not have to
reference the workbook at all. If that is not the case (ie you are pulling
data from another workbook that is open in the background, vlookup, match,
etc), I would name the 'other' WB as whatever so you can then call it as
needed to your activeworkbook (or worksheet).
Try something like this:
Sub SelectOtherWB()
Dim MyWBName As String
MyWBName = "TempFile.xls"
ActiveWorkbook.SaveAs "C:\" & MyWBName, FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
CreateBackup:=False
' ********* Your code here .. two samples given below .. use as needed
' Sample for having to reference another WB that is not your 'active' WB
which is open at
' the same time
VlookupMyData = Application.WorksheetFunction.VLookup _
(ActiveCell.Offset(0, -2),
Workbooks("TempFile.xls").Sheets("MyActiveSheet").Range("A
"), 4, 0)
' Sample of having a New WB / WS open and you wanting to select the 'other'
WB to have it active
Windows("TempFile.xls").Activate
End Sub
If your recorded macro is performing a bunch of calculations, formatting,
etc; then all you need to do is import the code into each workbook that you
need the VB to run on.
Hope this helps,
J