How to filter and change text in Macro

SCPbrito

Board Regular
Joined
Aug 1, 2024
Messages
61
Office Version
  1. 365
Platform
  1. Windows
I have this code below and I'm trying to filter anything in customer no that starts with a 6 using "6*" and then rename everything in customer name to "Cellphone Repair" and then filter all Customer No with "7*" and then change name to "Metro" and filter customer no with "8*" and change name to "Cricket".




ActiveSheet.Range("$A$1:$R$760").AutoFilter Field:=8, Criteria1:="=640011" _
, Operator:=xlOr, Criteria2:="=640113"
Range("I618").Select
ActiveCell.FormulaR1C1 = "Cellphone Repair"
Range("I618").Select
Selection.FillDown
ActiveSheet.ShowAllData
ActiveSheet.Range("$A$1:$R$760").AutoFilter Field:=8, Criteria1:=Array( _
"700001", "700011", "700058", "700158", "700176", "700241", "700320", "700567", _
"700653", "700996", "701230", "703963", "704059", "704063", "704069", "704084", _
"704086", "704138", "704366"), Operator:=xlFilterValues
Range("I723").Select
ActiveCell.FormulaR1C1 = "Metro PCS"
Range("I723").Select
Selection.FillDown
ActiveSheet.ShowAllData
ActiveSheet.Range("$A$1:$R$760").AutoFilter Field:=8, Criteria1:=Array( _
"800020", "800021", "800041", "800044", "800066", "800074", "800100", "800314", _
"800326", "800327", "800640"), Operator:=xlFilterValues
Range("I619").Select
ActiveCell.FormulaR1C1 = "Cricket"
Range("I619").Select
Selection.FillDown
ActiveSheet.ShowAllData
End Sub
 

Attachments

  • 2024-08-01_15-26-42.png
    2024-08-01_15-26-42.png
    63.7 KB · Views: 10

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Try this:

VBA Code:
Sub changeText()
  Dim i As Long
  
  Application.ScreenUpdating = False
  For i = 1 To Range("H" & Rows.Count).End(3).Row
    Select Case Left(Range("H" & i).Value, 1)
      Case "6": Range("I" & i).Value = "Cellphone Repair"
      Case "7": Range("I" & i).Value = "Metro PCS"
      Case "8": Range("I" & i).Value = "Cricket"
    End Select
  Next
  Application.ScreenUpdating = True
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,224,828
Messages
6,181,206
Members
453,022
Latest member
RobertV1609

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