简体   繁体   中英

assigning a value based on another column in Excel

I am trying to find a quick way to assign a value for a column depending on the value of another.I want to increase the value of column A by one each time the value of column B changes.

Column A    Column B

1           (520)998-7765
1           (520)998-7765
1           (520)998-7765
2           (450)877-4563
2           (450)877-4563
2           (450)877-4563
2           (450)877-4563
3           (650)989-7654
3           (650)989-7654
3           (650)989-7654
....        ....

I need to know if there is a formula that I can use to sort through 27,000 lines of data rather than assigning them one by one.

I am using a phone number as a unique identifier and I want the ID# to increase by one every time the phone number changes. Please Help!! 这是图像

Put value "1" in A2.

In A3 and after put the following function

=IF(B3=B2,A2,A2+1)

EDIT You can make a single formula for all of the rows.

Put something like this in A2 and copy it down:

=IF(ROW(A2)=2,1,IF(B2=B1,A1,A1+1))

It seems like you are trying to extract the unique list of phone numbers? If so, there is a Remove Duplicates function in Excel (under the Data tab) that should do what you need.

You would select your full range (27,000 phone numbers) and run Remove Duplicates . Excel would then leave behind a single row for each unique number.

I believe Remove Duplicates is available for Excel 2007 or later.

If you are using an older version of Excel, here is a link that gives more information on filtering for a unique list: Count unique values among duplicates

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM