今天,我试图替换点(。),但只有在来自sheet1的列表中的某个值与另一个工作表(另一个工作簿)的另一个列表中的某个值不匹配时,我才坚持使用此代码。 “参数不是可选的”是错误,但它不会给我任何其他提示。vba条件查找和替换
辅过滤器(WSS作为工作表,WSN作为工作表,我作为整数,J为整数,K为整数,L为整数,一个作为整数) ' ' 替代宏 ' Application.ScreenUpdating =假 范围( “A1”)。FormulaR1C1 = “排序” 集WSS =表( “工作表Sheet”) 集WSN =表( “non_confid”) COL1 = “A” COL2 = “E” COL3 = “C”
For a = 1 To 200
If wsS.Range(col1 & a) = wsN.Range("AB2:ab600") Then
a = a + 1
Else: Range(col1 & a).Replace What:=".", Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
a = a + 1
End If
Next
Range("a1").AutoFilter
ActiveWorkbook.Worksheets("sheet1").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("sheet1").AutoFilter.Sort.SortFields.Add Key:=Range("A:A"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("sheet1").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("a1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 15773696
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection.Font
.Color = -10477568
.TintAndShade = 0
End With
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$a$500"), , xlYes).Name = "Table1"
ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=1, Criteria1:="<>"
Set wsS = Sheets("sheet1") 'this has assigned the worksheet sheet1 to wsS
Set wsN = Sheets("non_confid") 'this has assigned the worksheet sheet1 to wsU
i = 2
For j = 2 To 300
If Not IsEmpty(wsS.Range(col1 & j).Value) Then
wsS.Range(col3 & i - 1).Value = wsS.Range(col1 & j).Value
i = i + 1
End If
Next
Range("A:B").EntireColumn.Delete
For k = 1 To 300
If IsEmpty(wsS.Range(col1 & k).Value) Then
i = i + 1 'Exit For 'this jumps out of the loop, so no more copying.
Else
wsN.Range(col2 & i).Value = wsS.Range(col1 & k).Value
i = i + 1
End If
Next
Sheets("non_confid").Select
Columns("A:G").EntireColumn.AutoFit
Range("e1").Select
ActiveSheet.ListObjects("Status").Range.AutoFilter Field:=4, Criteria1:="<>"
Range("A1").Select
ActiveWorkbook.Saved = True
Application.ScreenUpdating = True
End Sub
预先感谢您的时间!
我还有一些列将最终列表与更多列表进行比较,以查看结果是否与任何值匹配。诀窍是,由于我有两组值,所以我不希望使用2个工作簿,并且点无论如何都会产生差异 –