mikedbom
06-30-2011, 10:28 AM
i've been trying to modify this code for my worksheet but keep getting a type mismatch error at the worksheets("sheet10") declaration. I'm trying get my sheet to resolve all negative numbers to 0. Also, i dont want this code running the whole time, on command would be fine. Any help would be greatly appreciated.
Here is the code:
Sub ZeroNegatives()
Dim sheet As Worksheet
Dim cl As Range
For Each sheet In Worksheets("Sheet10")
For Each cl In sheet.Range("B4:F34")
If cl.Value < 0 Then
cl.Value = 0
Exit For
End If
Next cl
Next sheet
End
End Sub
Here is the code:
Sub ZeroNegatives()
Dim sheet As Worksheet
Dim cl As Range
For Each sheet In Worksheets("Sheet10")
For Each cl In sheet.Range("B4:F34")
If cl.Value < 0 Then
cl.Value = 0
Exit For
End If
Next cl
Next sheet
End
End Sub