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

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
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,224,823
Messages
6,181,182
Members
453,021
Latest member
Mohamed Magdi Tawfiq Emam

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