Hi,
I have a specific problem with some code, and then a general question to ask as well. I started learning/writing VBA code about 4 months ago; therefore, I apologize for my ignorance on a lot of this stuff; anyways, my general question would be,
1. Is there any general / simple way to use formulas in VBA? I've seen people use the Evaluate, as well as other methods, and am just confused as to when? and how? to use these methods. ; if you do not quite understand my question, my specific code question below gives a perfect example.
2. I am working on the code below, and can't get the DateDiff function to work, anybody know what I'm doing wrong?
I have a specific problem with some code, and then a general question to ask as well. I started learning/writing VBA code about 4 months ago; therefore, I apologize for my ignorance on a lot of this stuff; anyways, my general question would be,
1. Is there any general / simple way to use formulas in VBA? I've seen people use the Evaluate, as well as other methods, and am just confused as to when? and how? to use these methods. ; if you do not quite understand my question, my specific code question below gives a perfect example.
2. I am working on the code below, and can't get the DateDiff function to work, anybody know what I'm doing wrong?
Code:
Sub Assumed_Retention()
Application.ScreenUpdating = False
Dim LRA_WB As Workbook, Off_TC As String
Dim LRA_WS, LRA_WS2 As Worksheet
Dim Off_SC, ProformaDate, Off_SinceSC, Off_Since, Off_Retention, Off_RetentionSC, Off_Calc, C As Range
Set LRA_WB = ThisWorkbook
Set LRA_WS = LRA_WB.Worksheets("Rent_Roll")
Set LRA_WS2 = LRA_WB.Worksheets("List")
Set Off_SinceSC = LRA_WS.Range("E:E").Find(Off_TC, , xlValues, xlWhole).Offset(-1, 15)
Set Off_Since = Range(Off_SinceSC, Off_SinceSC.End(xlUp))
Off_TC = "Total Office"
Set Off_RetentionSC = LRA_WS.Range("E:E").Find(Off_TC, , xlValues, xlWhole).Offset(-1, 12)
Set Off_Retention = Range(Off_RetentionSC, Off_RetentionSC.End(xlUp))
Set ProformaDate = LRA_WS.Range("F11")
Off_Calc = Evaluate("DateDiff(" & ProformaDate.Address, Off_Since.Address, " & m & ")
For Each C In Off_Calc
If C > 9.99 Then
Off_Retention = 0.75
ElseIf C > 4.99 Then
Off_Retention = 0.5
ElseIf C > 2.99 Then
Off_Retention = 0.25
End If
Next C
Application.ScreenUpdating = True
End Sub