How can I do this?

T

Tmaxx02

I have a sheet with numbers in three columns.
I would like to have a formula or function to
look across the row and tell me if there is a
consecutive number. In other words:

A B C D
3 4 1 34

In column D, I'd like display the results 34 if
there are consecutive numbers.

Thanks in advance.
 
P

Pete_UK

Assuming your numbers are in row 1, try this in D1:

=IF(B1=A1+1,A1&B1,IF(C1=B1+1,B1&C1,""))

Note that this returns a text answer - if you had 10 in one cell and
11 next to it you would get 1011.

Hope this helps.

Pete
 
T

Tmaxx02

Both of these work with this exception: if 4 is before the 3, it
returns a blank.
I think that I could probably work this out though. Thanks very much,
I appreciate it.

Terry
 
T

T. Valko

This accounts for both ascending and descending values:
A B C D
3 4 1 34
4 3 1 43

=IF(ABS(A1-B1)=1,A1&B1&IF(ABS(B1-C1)=1,C1,""),IF(ABS(B1-C1)=1,B1&C1,""))

Biff
 
T

Tmaxx02

This accounts for both ascending and descending values:


=IF(ABS(A1-B1)=1,A1&B1&IF(ABS(B1-C1)=1,C1,""),IF(ABS(B1-C1)=1,B1&C1,""))

Biff
That worked great. It also accounted for more than 2 numbers. Thanks
very much.

Terry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top