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
 

Some videos you may like

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Watch MrExcel Video

Forum statistics

Threads
1,127,588
Messages
5,625,668
Members
416,125
Latest member
NeedExcelHelp2021

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
Top