VBA daydiff vs Monthdiff

rjmdc

Well-known Member
Joined
Apr 29, 2020
Messages
676
Office Version
  1. 365
Platform
  1. Windows
hi
my code seems to work for day difference but month diff is broken
i need that if daydiff >3 but less than 1 month then daydiff else month diff

Rich (BB code):
'Intake Date
        If IncludeAmendAppDate And AmendAppDate <> "" Then
            MonthsPassed = DateDiff("m", CDate(AmendAppDate), Date)
            DaysPassed = DateDiff("d", CDate(AmendAppDate), Date)
            If DaysPassed >= 3 And DaysPassed <= 29 Then
                .Range("A3:B3").Copy Destination:=.Range("A" & nr & ":B" & nr)
                .Cells(nr, "A") = "Amendment App. Date was " & AmendAppDate & ", " & DaysPassed & " days have passed since signature was requested."
            If MonthsPassed > 1 Then
                .Cells(nr, "A") = "Amendment App. Date was " & AmendAppDate & ", " & MonthsPassed & " months have passed.  Do you want to continue?"
                .Range("A" & nr & ":B" & nr).Font.Color = 255
'            ElseIf MonthsPassed >= 3 Then
'                .Cells(nr, "A") = "Amendment App. Date was " & AmendAppDate & ", " & MonthsPassed & " months have passed.  Do you want to continue?"
'                .Range("A" & nr & ":B" & nr).Font.Color = 255
            Else
                .Cells(nr, "A") = "Amendment App. Date was " & AmendAppDate & ", " & MonthsPassed & " month has passed.  Do you want to continue?"
            End If
            .Cells(nr, "B").ClearContents
            .Range("A" & nr & ":B" & nr).Merge
            .Range("A" & nr & ":B" & nr).Font.Size = 9
            nr = nr + 1
        End If

please help me
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
1) What kind of "broken"? any warning message? which line was hightlighted?
2) Could you share full code?
 
Upvote 0

Forum statistics

Threads
1,215,778
Messages
6,126,841
Members
449,343
Latest member
DEWS2031

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top