ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can I use HLookup with an internally defined array? (https://www.excelbanter.com/excel-programming/436004-can-i-use-hlookup-internally-defined-array.html)

plh[_5_]

Can I use HLookup with an internally defined array?
 
That is, one that is not taken from the spreadsheet.
Before I start banging my head against the wall, I thought I would ask
the experts!
Something like:

Sub MySub
Dim HLookupArray as Variant
Dim n,m as Long
n = Something
m = SomethingElse
LookupVal = SomethingElseYet
HLookupArray = Array(n,m)

(In hear put code assigning values to the array nodes)

SlowWalker = Application.HLookup(LookupVal, HLookupArray, 4, False)

End Sub

Thank You,
-plh

Charles Williams

Can I use HLookup with an internally defined array?
 
Yes, something like that or using VLOOKUP should work (but its probably
slower than just searching the array with a loop, unless the array is
sorted)


Charles
___________________________________
The Excel Calculation Site
http://www.decisionmodels.com

"plh" wrote in message
...
That is, one that is not taken from the spreadsheet.
Before I start banging my head against the wall, I thought I would ask
the experts!
Something like:

Sub MySub
Dim HLookupArray as Variant
Dim n,m as Long
n = Something
m = SomethingElse
LookupVal = SomethingElseYet
HLookupArray = Array(n,m)

(In hear put code assigning values to the array nodes)

SlowWalker = Application.HLookup(LookupVal, HLookupArray, 4, False)

End Sub

Thank You,
-plh




plh[_5_]

Can I use HLookup with an internally defined array?
 
On Nov 10, 9:42*am, "Charles Williams"
wrote:
Yes, something like that or using VLOOKUP should work (but its probably
slower than just searching the array with a loop, unless the array is
sorted)

Charles
___________________________________
The Excel Calculation Sitehttp://www.decisionmodels.com

"plh" wrote in message

...

That is, one that is not taken from the spreadsheet.
Before I start banging my head against the wall, I thought I would ask
the experts!
Something like:


Sub MySub
Dim HLookupArray as Variant
Dim n,m as Long
n = Something
m = SomethingElse
LookupVal = SomethingElseYet
HLookupArray = Array(n,m)


(In hear put code assigning values to the array nodes)


SlowWalker = Application.HLookup(LookupVal, HLookupArray, 4, False)


End Sub


Thank You,
-plh


Thank You! I would have thought it would be faster in general.
-plh


All times are GMT +1. The time now is 06:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com