Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Switching Between 2 workbooks using VBA

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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

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
Switching between Workbooks Doekoe Excel Discussion (Misc queries) 0 May 5th 08 10:54 AM
Switching between workbooks Jim Excel Discussion (Misc queries) 5 July 28th 07 03:19 AM
switching between workbooks... safdarhassan Excel Programming 3 August 12th 06 01:06 PM
Switching Workbooks in vbscript Joe[_3_] Excel Programming 1 August 25th 04 09:09 PM
Switching Names Around D[_6_] Excel Programming 1 August 17th 04 08:07 AM


All times are GMT +1. The time now is 11:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"