Convert a string to a Range??

websmythe

New Member
Joined
Apr 1, 2009
Messages
16
Hi, I'm working in Excel 2003. Is there a way to convert strings to Ranges on the Excel commandline?

I have a lookup function in an estimate sheet that uses 2 ranges, stored as strings, in another worksheet. They are used to return a price from another workbook. When I use named ranges to access them with the lookup function, it doesn't work. But when I cut and paste the strings into the commandline it works prefectly??

I'm stumped... I've looked everywhere I can think of, could anyone offer some suggestions? Thanx.

Code:
$A10 = Part Number to search for
 
MaterialOptions is a named Range 
eg: '[Catalog.xls]PriceList'!$A$13:$A$17
 
PriceOptions is a named Range  
eg: '[Catalog.xls]PriceList'!$Z$13:$Z$17
 
LOOKUP($A10,MaterialOptions,PriceOptions) = #VALUE!
But...
LOOKUP($A10,'[Catalog.xls]PriceList'!$A$13:$A$17,'[Catalog.xls]PriceList'!$Z$13:$Z$17) = Success!
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Are your names defined in the workbook containing the formula? I can't reproduce your problem if they are.
 
Upvote 0
Thanx for the reply.
Hope this image isnt too convoluted.

http://img9.imageshack.us/img9/8268/failedv.jpg

Cell G14 is totally successful,
but, has the addresses from J14 and K14 pasted into the commandline,
so I fgure they are behaving like ranges

Cell G12 is the culprit.
So only thing I can figure is that J12 & K12 are not being treated as ranges, so it doesnt want to go get the data.
 
Upvote 0
Oh ya, as I was saying... as you can see
J12, K12, J14 & K14 are Ranges for Material Options and Price Options
(from a separate "Catalog" Workbook) which are stored in the Items worksheet

Probably, not the most elegant way to handle things,
but hey, I can learn :)
 
Last edited:
Upvote 0
In trying to solve this problem using VBA, even tho Help says that
"LOOKUP, VLOOKUP & HLOOKUP are available to VBA",
when I try to use them I get a "Compile Error: Sub or Function not defined".
Is that related to the issue??
 
Upvote 0
To use thos functions in VBA you have to qualify them with their parent, the WorksheetFunction object. Example:

Code:
x = WorksheetFunction.VLookup("Range("A1").Value, Range("B1:C100"), 2, False)
 
Upvote 0
Thanks for that.

Got the function to work in VBA,
except it's still only returning a string like it did on the formula bar...
eg: '[Catalog.xls]Summary'!$Z$13:$Z$17 ...which happens to be the same as the ResultVector
...instead of the cell value Im trying to lookup.

Definately a step in the right direction tho, cause at least it's returning something :)
I think it must be the way I'm trying to use the reference. Maybe cause its in another workbook??
Rich (BB code):
Function GetPrice(LookupVal, LookupRng, ResultRng)
 
' Get lookup ranges from the Items worksheet sheet
' and use them to get the respective price from the external Catalog workbook
 
    Set LookupVector = LookupRng    ' make sure its a range
    Set ResultVector = ResultRng    ' make sure its a range
 
    GetPrice = WorksheetFunction.Lookup(LookupVal, LookupVector, ResultVector)
 
End Function
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,399
Members
448,957
Latest member
Hat4Life

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top