简体   繁体   中英

Excel macro to insert certain characters into column

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

在此处输入图像描述

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM