Excel Forumla

Hi,

I wondered if there was a way that I could take the number used in a cell to help form an IF statement.

For example I have a row of cells:
Level 1 Level 2 Level 3 Level 4 Level 5

Could I write a statement that will use the number 1, 2, 3, 4, or 5 from above rather than using the word "Level 1" etc.

Is this possible?

Thanks

Comments

  • Smiley433Smiley433 Posts: 7,895
    Forum Member
    I'd use a formula like this in cell B1...

    =VALUE(TRIM(RIGHT(A1,2)))

    where A1 is the cell containing your "Level 1" text amd the "2" at the end of the formula is the number of numeric digits your levels might contain. So if you have up to 99 levels then keep it at 2, if you have 100-999 levels then change it to 3 but if you've no more than 9 levels then change it to 1. Then copy the formula to B2, B3, etc.

    But I'm sure someone will offer a better solution.
  • jimboyjimboy Posts: 411
    Forum Member
    Just in case you have more than 100 rows, this will find the space and return the number to the right of it:

    =VALUE(RIGHT(A1,LEN(A1)-FIND(" ",A1,1)))
  • jsmith99jsmith99 Posts: 20,382
    Forum Member
    ✭✭✭
    Smiley433 wrote: »
    I'd use a formula like this in cell B1...

    =VALUE(TRIM(RIGHT(A1,2)))

    where A1 is the cell containing your "Level 1" text amd the "2" at the end of the formula is the number of numeric digits your levels might contain. So if you have up to 99 levels then keep it at 2, if you have 100-999 levels then change it to 3 but if you've no more than 9 levels then change it to 1. Then copy the formula to B2, B3, etc.

    But I'm sure someone will offer a better solution.

    That would only work if the values were Level01, Level02, etc. Though for the '2' you could substitute the Excel equivalent of (LEN(A2)-5).
Sign In or Register to comment.