Hi OllyXLS,
Thanks for your assitance. Have 1 more question...
I am trying to give background clor for those cells that are less than 500K, but getting struck. Any assistance!!!
here is the code which i have got struck...
Sub Test()
Dim ws As Worksheet
Dim lRow As Long
Set ws = ThisWorkbook.Sheets("Sheet1")
With ws
lRow = .Range("D" & .Rows.Count).End(xlUp).Row
.Range("E4:E" & lRow).Formula = "=If(D4>=0,0,D4)"
'.Range("F4").Formula = "=SUM(" & Range(Cells(4, -1), Cells(i)).Address(True, False) & ")"
.Range("E4:E" & lRow).Value = .Range("E4:E" & lRow).Value
.Range("F4:F" & lRow).Formula = "=If(E4<>0,sum(E$3:E4),"""")"
.Range("F4:E" & lRow).Value = .Range("F4:F" & lRow).Value
If (Range("F4:F" & lRow).Value) <= 500000 Then
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark2
.TintAndShade = -9.99481185338908E-02
.PatternTintAndShade = 0
End With
Else
Range("A1").Select
End If
End With
End Sub
Thanks!
Bookmarks