I'm trying do a macro in excel that clear cells for A1:A100 but I have only find a macro that can do that to one cell. How can I make it work for more cells?
Sub ClearCell()
Dim Rng As Range
Set Rng = ActiveSheet.Range("A1")
Dim i As Long
For i = 1 To 10
If Rng.Cells(i,1) = "" Then
Rng.Cells(i,1).ClearContents
End If
Next i
End Sub
try this:
Sub test()
Dim Cl As Range
For Each Cl In [A1:A100]
If Cl.Value = "" Then
With Cl
.ClearFormats
.ClearContents
End With
End If
Next Cl
End Sub
better yet, try this:
Sub foo()
Range("A1:A100").ClearContents
Range("A1:A100").ClearFormats
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.