Home > other >  Excel macro to insert certain characters into column
Excel macro to insert certain characters into column

Time:05-16

Im currently using this. while this works for now. Im looking to add code that allows me replace everything in that column. Not just limited to only replacing the 0 or one word.

.AutoFilter field:=6, Criteria1:="0"
Columns("F").replace What:="0", Replacement:="Not Needed", Lookat:=xlPart, searchOrder:=xlByRows, MatchCase:=False, Searchformat:=False, ReplaceFormat:=False
Worksheets("Sheet1").AutoFilterMode = False

CodePudding user response:

enter image description here

Sub test()
Dim rg As Range
    With ActiveSheet
        Set rg = .Range("A1", .Range("C" & Rows.Count).End(xlUp)) 'change as needed
            With rg
                .AutoFilter Field:=3, Criteria1:="=0", Operator:=xlAnd 'change as needed
                .Resize(.Rows.Count - 1, .Columns.Count).Offset(1, 0).SpecialCells(xlCellTypeVisible).Value = "X"
                .AutoFilter
            End With
    End With
End Sub
  • Related