我想排序两个相同的数字,但我只想更改其中一个。
Sub replace_sales()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
For i = 1 To 10000
If ws.Cells(i, 1) = "1932597" Then
ws.Cells(i, 9) = "0"
End If
Next i
Next ws
End Sub
答案 0 :(得分:0)
在第一次匹配时放置并Exit For
退出当前的ws
工作表循环:
Sub replace_sales()
Dim ws As Worksheet
Dim i As Long
For Each ws In ActiveWorkbook.Worksheets
For i = 1 To 10000
If ws.Cells(i, 1) = "1932597" Then
ws.Cells(i, 9) = "0"
Exit For
End If
Next i
Next ws
End Sub