troubleshooting Question

VBA code to return end of previous month (if cell is blank)

Avatar of pdvsa
pdvsaFlag for United States of America asked on
Microsoft OfficeMicrosoft Excel
2 Comments1 Solution66 ViewsLast Modified:
Experts,

How can I change the row  rCell2.Value = Date - Day(Date)  to return the end of the previous month if there is no data in the cell?
Right now, the code works as planned in all cases but returns a blank if the cell is blank.

   
 Range(Selection, Selection.End(xlDown)).Select
    Dim rCell2 As Range

    For Each rCell2 In Selection
        If IsDate(rCell2) And Not rCell2.HasFormula Then
             rCell2.Value = Date - Day(Date)
        End If
    Next rCell2


thank you very much
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros