Switching Between 2 workbooks using VBA
The following gets a value from Book1 and looks for it in Book2:
Sub demo()
Dim r1 As Range
Dim r2 As Range
Set r1 = Workbooks("Book1").Worksheets("Sheet1").Range("A1" )
v = r1.Value
Workbooks("Book2").Activate
Sheets("Sheet1").Activate
For Each r In ActiveSheet.UsedRange
If r.Value = v Then
MsgBox (r.Address)
Exit For
End If
Next
End Sub
using Sheet1 in both books
--
Gary's Student
"Isit Ears" wrote:
How do you switch between 2 open workbooks using a macro. Both workbooks
would already be open but I need to be able to pick a value from one, then
look for it in the 2nd workbook and then repeat.
Thanks
|