Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 86
  • Last Modified:

Add a new value based on adjacent value

The lookup values are cube numbers produced by checking against other values in the spreadsheet and are part of one of the following 4 groups (A1, A2, A3, A4) where A represents an area and C represents a cube number.

C1-C280 - member of area 4
C282-C448 - member of area 3
C454-C648 - member of area 2
C659-C894 - member of area 1

The lookup values (cube numbers) are in column W, and I need area numbers to fill for column V once a cube number exists in column W.  If a cube number does not yet exist in column W, then I want for nothing to occur in column V.

Assistance is greatly appreciated.
0
frugalmule
Asked:
frugalmule
  • 2
3 Solutions
 
RayData AnalystCommented:
Will the values in Column W be a number (such as: 282 or 648 etc) or will it contain a 'C' plus a number?  
And you then want a number (1,2,3 or 4) in Column V (blank if nothing in W)?
0
 
Glenn RayExcel VBA DeveloperCommented:
I presume that cube numbers are listed as "C###" and you want the area values returned as A1-A4.  Because the area numbers are grouped by sequential sets of cube numbers you can use a lookup function to resolve this.

1) Set up a lookup table (on another sheet, ideally).  In one column you'll have a cube numbers, but only the starting numbers for each area.  In the second column you'll show the appropriate area number.  Like so:
cube lookup
Note that I've also included an "error" result in case a cube value is found exceeding the area definitions.

2) In column V you'll insert a lookup formula like so (note the sheet name where I put the lookup table from the above step is titled "Lookups"
=VLOOKUP(VALUE(MID(W2,2,10)),Lookups!$A$2:$B$6,2,TRUE)

This is looking at the numerical value of the cube (after the "C") and returning the ordered/sorted result in the lookup table.

See the example workbook.  It randomly generates cube numbers so you can see the results change.

Regards,
-Glenn
EE-Q28585336.xlsx
0
 
Glenn RayExcel VBA DeveloperCommented:
I just realized that your area definitions have some gaps in the cube numbers, so I've updated the lookup table to handle that.  If a Cube number appears between valid area definitions (ex., C650), the word "Invalid" will display.  See attached revised example file.

-Glenn
EE-Q28585336.xlsx
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now