I would like to use a macro to clear (not delete) all cells in column AA that contain a 1 or 0. I've sorted through various threads, but can't seem to find one that will work for me. Can someone point me in the right direction?
Sub ClearAA()
Dim r As Long
Dim lrow As Long
Application.ScreenUpdating = False
lrow = Range("AA" & Rows.Count).End(xlUp).Row
For r = lrow To 1 Step -1
If Cells(r, 27).Value = 0 Or Cells(r, 27).Value = 1 Then
Cells(r, 27).ClearContents
End If
Next r
Application.ScreenUpdating = True
End Sub
Public Sub Clear10()
Dim CC As Range
For Each CC In Selection
If CC.Value = 1 Or CC.Value = 0 Then
CC.ClearContents
End If
Next CC
End Sub
What else other than 1 or 0 might appear in column AA ?
Many different numbers, everything from a 2 to 500 and everything in between...that's the problem. So maybe a vlookup wouldn't be ideal.
Sub test()
Dim LR As Long, i As Long, PrevCalc As Variant
With Application
.EnableEvents = False
.ScreenUpdating = False
PrevCalc = .Calculation
.Calculation = xlCalculationManual
End With
LR = Range("AA" & Rows.Count).End(xlUp).Row
For i = 1 To LR
If Range("AA" & i).Value = 0 Or Range("AA" & i).Value = 1 Then Range("AA" & i).ClearContents
Next i
With Application
.EnableEvents = True
.ScreenUpdating = True
.Calculation = PrevCalc
End With
End Sub
Wow, that works perfectly! Super fast. So I know what Screenupdating is, but what are the Events and Calculation?