Change values in column C based on comparison of previous cells in column A

Bakacaca

New Member
Joined
Nov 20, 2020
Messages
1
Office Version
  1. 365
Platform
  1. Windows
I have a spread sheet with "Property IDs" that each have multiple "rooms" assigned to them. I need to change the "Room Name" in a seperate column based on how many times the Property ID has been Listed.

Example:

I need this:
1605897170284.png


To be this:
1605897225892.png


The reason I am looking for a macro or formula is because there are 46,000 rows in this sheet.
Thank you so very much for your help. I do have some code written, but I only started researching how to write it about 4 hours ago and It's nowhere near accurate I believe. Here is what I currently have, but I was messing around with the methods and objects to try and figure it out so it's kind of all over the place atm.

VBA Code:
Sub Change_Room_Number()
'
' Change_Room_Number Macro
'

'

'Select Sheet 1
Worksheets("Sheet1").Activate

'Select Column A
Range("A:A").Select


'Declare Variable Site ID
SiteID = Range("A:A").Value
    
'Run If statement to determine Value of Room Number
    If SiteID = ActiveCell.Offset(-16, 0).Value Then
        RoomNumber = "Room 17"
    ElseIf SiteID = ActiveCell.Offset(-15, 0).Activate Then
        RoomNumber = "Room 16"
    ElseIf SiteID = ActiveCell.Offset(-14, 0).Activate Then
        RoomNumber = "Room 15"
    ElseIf SiteID = ActiveCell.Offset(-13, 0).Activate Then
        RoomNumber = "Room 14"
    ElseIf SiteID = ActiveCell.Offset(-12, 0).Activate Then
        RoomNumber = "Room 13"
    ElseIf SiteID = ActiveCell.Offset(-11, 0).Activate Then
        RoomNumber = "Room 12"
    ElseIf SiteID = ActiveCell.Offset(-10, 0).Activate Then
        RoomNumber = "Room 11"
    ElseIf SiteID = ActiveCell.Offset(-9, 0).Activate Then
        RoomNumber = "Room 10"
    ElseIf SiteID = ActiveCell.Offset(-8, 0).Activate Then
        RoomNumber = "Room 9"
    ElseIf SiteID = ActiveCell.Offset(-7, 0).Activate Then
        RoomNumber = "Room 8"
    ElseIf SiteID = ActiveCell.Offset(-6, 0).Activate Then
        RoomNumber = "Room 7"
    ElseIf SiteID = ActiveCell.Offset(-5, 0).Activate Then
        RoomNumber = "Room 6"
    ElseIf SiteID = ActiveCell.Offset(-4, 0).Activate Then
        RoomNumber = "Room 5"
    ElseIf SiteID = ActiveCell.Offset(-3, 0).Activate Then
        RoomNumber = "Room 4"
    ElseIf SiteID = ActiveCell.Offset(-2, 0).Activate Then
        RoomNumber = "Room 3"
    ElseIf SiteID = ActiveCell.Offset(-1, 0).Activate Then
        RoomNumber = "Room 2"
    Else
        RoomNumber = "Room 1"
    End If
    
'Declare the result of the If statement as the Variable RoomNumber and place it in the corresponding column
Range("C").Value = RoomNumber
    
End Sub
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Welcome to the MrExcel forum!

You should be able to do that with just a formula:

Book2
ABCDE
1Property IDSq.FtRoom NumberFloor TypeQuantity
21450Room 1Tile1
31450Room 2Carpet2
41450Room 3Wood2
54582Room 1Tile3
64282Room 2Tile2
72256Room 1Tile1
82256Room 2Wood4
92256Room 3Wood2
102256Room 4Wood1
112256Room 5Carpet3
125600Room 1Tile3
135600Room 2Tile3
145600Room 3Tile3
Sheet1
Cell Formulas
RangeFormula
C2:C14C2="Room "&COUNTIF($A$2:$A2,$A2)
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,155
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top