HI VBA Gurus,
I have a spreadsheet with data from A17 to AG1000. Column B is used for inserting appropriate dates and I want to calculate number of days using VBA in column AH and the code I have been playing with is:-
Sub Summary_Dates()
Dim ws1 As Worksheet
Dim Date1 As Date
Dim Date2 As Date
Dim DateDiff As Date
Dim NumberDays As Integer
Dim MyRng1 As Long
Dim r As Long
Set ws1 = Worksheets("CREDIT TRACKER")
MyRng1 = ws1.Range("AG1000").Row
For r = n To 1 Step -1
If MyRng1 = "USE" Then
Range("AH17").Value = ""
ElseIf MyRng1 = "YES" Then
Exit Sub
Else
Date1 = DateValue(Range("B17"))
Date2 = Date
DateDiff = Date2 - Date1
NumberDays = Int(DateDiff)
Range("AH17").Value = NumberDays + 1
End If
Next r
End Sub
Please can you help.
Rgds
Bookmarks