ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Lookup problems? (https://www.excelbanter.com/excel-discussion-misc-queries/239099-lookup-problems.html)

Derrick

Lookup problems?
 
I have a problem. i have some code in VBA that returns the contents of a cell
from another sheet - steel description:
C3 x 4.1
C5 x 6.2
2 x 2
2 x 4
1 x 1 x .125
etc.
It is returned by using
CalcSht.cells(NewRow, ListCol) = Description
whe NewRow, List Col give the location.. ie (2,3) for Cell C2 on my
calcSht.
Description = DataSht.Range("A"&Rowcounter) - for getting the specific row...

so. it then can print C3 x 4.1 exactly as it was in the Data sheet on the
Calc sheet.
THEN: i use Lookup(Value, LookupArray, ReturnArray) to lookup the steel
description, and return other properties that are related to that specific
steel type.
=Lookup(C2, 'Steel'!A1:A5,'Steel'!B1:B5) for example.

Herein lies my problem. any steel size with 'C' preceding the dimensions
are ignored...and automatically lookup returns the bottom number.
Why would there be a difference in the cells so that it doesnt recognize the
cell contents?
can anyone help me?

T. Valko

Lookup problems?
 
=Lookup(C2, 'Steel'!A1:A5,'Steel'!B1:B5)

The LOOKUP function *requires* that the data be sorted in ascending order:

1 x 1 x .125
2 x 2
2 x 4
C3 x 4.1
C5 x 6.2

If you don't want to/can't sort the data then use VLOOKUP:

=VLOOKUP(C2,Steel!A1:B5,2,0)

--
Biff
Microsoft Excel MVP


"Derrick" wrote in message
...
I have a problem. i have some code in VBA that returns the contents of a
cell
from another sheet - steel description:
C3 x 4.1
C5 x 6.2
2 x 2
2 x 4
1 x 1 x .125
etc.
It is returned by using
CalcSht.cells(NewRow, ListCol) = Description
whe NewRow, List Col give the location.. ie (2,3) for Cell C2 on my
calcSht.
Description = DataSht.Range("A"&Rowcounter) - for getting the specific
row...

so. it then can print C3 x 4.1 exactly as it was in the Data sheet on the
Calc sheet.
THEN: i use Lookup(Value, LookupArray, ReturnArray) to lookup the steel
description, and return other properties that are related to that specific
steel type.
=Lookup(C2, 'Steel'!A1:A5,'Steel'!B1:B5) for example.

Herein lies my problem. any steel size with 'C' preceding the dimensions
are ignored...and automatically lookup returns the bottom number.
Why would there be a difference in the cells so that it doesnt recognize
the
cell contents?
can anyone help me?





All times are GMT +1. The time now is 07:59 PM.

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