dear Team,
I am using the bellow code for calculating my values.
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim ws As Worksheet, lRow As Long, DifValue As String
Set ws = ThisWorkbook.Sheets("Master Data")
With ws
lRow = .Range("T" & .Rows.Count).End(xlUp).Row
.Range("E4:E" & lRow).Formula = "=250 - (T4-L4)"
.Range("F4:F" & lRow).Formula = "=600 - (T4-M4)"
.Range("G4:G" & lRow).Formula = "=1000 - (T4-N4)"
.Range("H4:H" & lRow).Formula = "=1000 - (T4-O4)"
.Range("I4:I" & lRow).Formula = "=1000 - (T4-P4)"
.Range("K4:K" & lRow).Formula = "=2000 - (T4-R4)"
If .Range("C" & lRow).Value = "LW300FV(ARAI)" Then
.Range("J4:J" & lRow).Formula = "=2000 - (T4-Q4)"
Else
.Range("J4:J" & lRow).Formula = "=1000 - (T4-Q4)"
End If
' .Range("W4:W" & lRow).Formula = DateDiff("D", CDate(.Range("V4")), Now)
Dim LastRow As Long, i As Long
LastRow = .Cells(.Rows.Count, "C").End(xlUp).Row
For i = 4 To LastRow
If .Range("V" & i).Value = "" Then
.Range("W" & i).Value = ""
Else
.Range("W" & i).Value = DateDiff("d", .Range("V" & i).Value, Date)
End If
If .Range("W" & i).Value >= 30 Then
.Range("U" & i).Value = ""
.Range("V" & i).Value = ""
End If
Next i
End With
End Sub
In above code all are working except If condition on
If .Range("C" & lRow).Value = "LW300FV(ARAI)" Then .Range("J4:J" & lRow).Formula = "=2000 - (T4-Q4)"
Else
.Range("J4:J" & lRow).Formula = "=1000 - (T4-Q4)"
End If
When ever i am using this condition this will run the Else condition only.
Can any one help me where and what is the mistake i am doing on this