LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default VLookup to a different workbook

I got this code from another thread but am having trouble modifying it.
The code is in module1 on worksheet.xlsm but I want to look up something on
an ALREADY OPEN workbook CreateManifestEmail_V1.xlsm

I get "Subscript out of range" at <-- ERROR shown below in code.

Your help is appreciated in advance.

~~~~~~~~~~~~

Function LookupEmailNames (sServer As String) As String
' looks at CreateManifestEmail_V1.xlsm (eMail Names) for sServer in Col A
' returns TO names from Col B

Dim OFFICE As Workbook
Dim Result As String
Dim EmailRange As Variant 'it can return a blank

Set OFFICE = Workbooks("CreateManifestEmail_v1.xlsm") <- ERROR
With OFFICE.Worksheets("eMail Names")
Set EmailRange = .Range("A1:B1000")
End With

Result = Application.VLookup(sServer, EmailRange, 2, False)

If IsError(Result) Then
MsgBox "Not found"
Else
MsgBox Result, vbOKOnly
End If

End Sub

--
Thanks for your reply & assistance.
Jimbo213
 
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
vlookup from one workbook to another Melbridge Excel Programming 0 January 27th 09 12:54 PM
vlookup other workbook swell estimator[_2_] Excel Discussion (Misc queries) 1 September 9th 08 07:10 PM
Vlookup in another workbook Luis A. Vázquez Excel Programming 1 September 27th 07 10:15 PM
Vlookup on second WorkBook Patrick Simonds Excel Programming 8 October 15th 06 11:00 PM
VLOOKUP into another workbook L Mehl Excel Programming 6 February 5th 04 05:45 AM


All times are GMT +1. The time now is 12:21 PM.

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

About Us

"It's about Microsoft Excel"