Excel tips: Finding the Last Day of a Given Month
=DATE(YEAR(TODAY()),MONTH(TODAY())+num_mths,0)
where num_mths = 0 for the end of month for the current month and num_mths = 1 for the end of the month for the next month, etc.
1. Tried the formula if num_months = 0, it gives the end date for the prev