求助一个EXCEL VBA 代码问题?

2025-01-02 17:21:03
推荐回答(2个)
回答1:

试试以下代码
Sub 清空()
Dim m As Range
Dim n As Range
Set m = Range("C1:G" & ActiveSheet.UsedRange.Rows.Count)
For Each n In a.Cells
If InStr(n, "-") > 0 Then
n = ""
End If
Next
End Sub

回答2:

假设数据表有100行
sub test()
dim a as range
dim b as range
set a=range("C1:D100")
for each b in a.cells
if instr(b.text,"-")>0 then
b.text=""
end if
next b
end sub