Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
DG DG is offline
external usenet poster
 
Posts: 46
Default Application.VLookup and External files

I want to use Application.VLookup to find values in an excel spreadsheet on
a network.

I'm not sure of the syntax, especailly the " or ' and !.

Here is what I have:

In Sheet1 of Book3.xls I have this in a vba module:

Sub FindPrice()
cells(a,1) = Application.VLookup("PRM 8018539",'\\myserver01\PRICE
UPDATES\[IPRICE 1.xls]'!sheet1.range("B2",Range("C65536").End(xlUp)),fal se)
End Sub

Exactly as is returns Compile Error: Expected: expression ant the first
single quote in front of myserver.

If I change both single quotes to double quotes I get: Compile Error:
Expected: list separator or ).

Help.

DG


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Application.VLookup and External files

You have a couple of choices.

#1. You can open the file and then use application.vlookup() against that open
file.

Dim iPrWks as worksheet
dim iPrRng as range
dim res as variant 'could be an error

set iprwks = workbooks.open _
(filename:="\\myserver01\price updates\iprice 1.xls",
_ readonly:=true).worksheets("Sheet1")

with iprwks
set iprRng = .range("B2",.cells(.rows.count,"C").end(xlup))
end with

'return the second column of the range????
res = application.vlookup("prm 8018539", iprrng, 2, false)

if iserror(res) then
res = "No match"
end if

activesheet.cells(a,1).value = res

#2. You could build a formula and plop it into that cell. Then convert it to
values:

With activesheet.cells(a,1)
.formula = "=vlookup(""PRM 8018539""," _
& "'\\myserver01\PRICE UPDATES\[IPRICE 1.xls]'!sheet1!b:c,2,false)"
.value = .value
end with

Notice that the double quotes surrounding strings are doubled up. And I changed
the range to B:C instead of limiting the rows.







DG wrote:

I want to use Application.VLookup to find values in an excel spreadsheet on
a network.

I'm not sure of the syntax, especailly the " or ' and !.

Here is what I have:

In Sheet1 of Book3.xls I have this in a vba module:

Sub FindPrice()
cells(a,1) = Application.VLookup("PRM 8018539",'\\myserver01\PRICE
UPDATES\[IPRICE 1.xls]'!sheet1.range("B2",Range("C65536").End(xlUp)),fal se)
End Sub

Exactly as is returns Compile Error: Expected: expression ant the first
single quote in front of myserver.

If I change both single quotes to double quotes I get: Compile Error:
Expected: list separator or ).

Help.

DG


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Application.VLookup and External files

I messed up the second suggestion. (I wasn't careful enough with my exclamation
points and apostrophes!



#2. You could build a formula and plop it into that cell. Then convert it to
values:

With activesheet.cells(a,1)
.formula = "=vlookup(""PRM 8018539""," _
& "'\\myserver01\PRICE UPDATES\[IPRICE 1.xls]sheet1'!b:c,2,false)"
.value = .value
end with

DG wrote:

I want to use Application.VLookup to find values in an excel spreadsheet on
a network.

I'm not sure of the syntax, especailly the " or ' and !.

Here is what I have:

In Sheet1 of Book3.xls I have this in a vba module:

Sub FindPrice()
cells(a,1) = Application.VLookup("PRM 8018539",'\\myserver01\PRICE
UPDATES\[IPRICE 1.xls]'!sheet1.range("B2",Range("C65536").End(xlUp)),fal se)
End Sub

Exactly as is returns Compile Error: Expected: expression ant the first
single quote in front of myserver.

If I change both single quotes to double quotes I get: Compile Error:
Expected: list separator or ).

Help.

DG


--

Dave Peterson
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
Launch external application SP[_7_] Excel Programming 3 February 27th 07 12:14 AM
Open an external application PaulW Excel Discussion (Misc queries) 8 November 16th 06 05:12 PM
SOS: Connecting to External Application (AS400C) Baapi Excel Programming 0 March 1st 06 06:30 PM
Linking from external application Crystal Thomas Cox Excel Discussion (Misc queries) 1 November 15th 05 01:17 PM
Close External Application using VBA ZABU Excel Programming 9 June 8th 04 03:33 AM


All times are GMT +1. The time now is 05:59 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"