Replace certain values in a column

larryresick

New Member
Joined
Dec 21, 2017
Messages
6
Here has got to be a better way to do this. This takes forever and gives me a run time error. I want to change the value of the cell only if it is NOT one of the four IFS. I probably want a find and replace but only if it is on condition it is not one of the four values (Player Tier, Veteran Tier, Preferred Tier, Platinum Tier).



Dim i As Integer


i = 2
Do While i <= ThisWorkbook.ActiveSheet.UsedRange.Rows.Count


If ThisWorkbook.ActiveSheet.Cells(i, 9) = "Player Tier" Then GoTo Line12
If ThisWorkbook.ActiveSheet.Cells(i, 9) = "Veteran Tier" Then GoTo Line12
If ThisWorkbook.ActiveSheet.Cells(i, 9) = "Preferred Tier" Then GoTo Line12
If ThisWorkbook.ActiveSheet.Cells(i, 9) = "Platinum Tier" Then GoTo Line12
ThisWorkbook.ActiveSheet.Cells(i, 9).Value = "Player Tier"


Line12: i = i + 1
Loop


End Sub

Thanks in advance
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Try this:
Code:
Sub MyMacro()

    Dim i As Integer

    Application.ScreenUpdating = False

    i = 2
    Do While i <= ThisWorkbook.ActiveSheet.UsedRange.Rows.Count
        If (Cells(i, 9) <> "Player Tier") And _
            (Cells(i, 9) <> "Veteran Tier") And _
            (Cells(i, 9) <> "Preferred Tier") And _
            (Cells(i, 9) <> "Platinum Tier") Then
            Cells(i, 9).Value = "Player Tier"
        End If
        i = i + 1
    Loop

    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0
Possibly :

Code:
Sub FT()
Dim r$
r = Range(Cells(2, 9), Cells(ActiveSheet.UsedRange.Rows.Count, 9)).Address
Range(r) = Evaluate("IF((" & r & "<>""Veteran Tier"")*(" & r & _
    "<> ""Preferred Tier"")*(" & r & "<>""Platinum Tier""),""Player Tier""," & r & ")")
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,262
Members
452,627
Latest member
KitkatToby

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