• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

TextBox Show Last Date of Month

delta

Member
TextBox1 Show Last Date of Month
TextBox2 Show First Date of Month

TextBox 3 Show Current Date

formula is
TextBox3 = Format(Date, "dd/mm/yyyy") e.g (11/08/2021)

show last date of month forumula

.TextBox2 = Format(CDate(Application.WorksheetFunction.EoMonth(.TextBox3.Value, 0)), "dd/mm/yyyy")

but this macro show 30/11/2021 date instead of date show is 31/08/2021

plse correct the code
 
Last edited:
What about?
Code:
TextBox2.Value = Format(DateSerial(Year(TextBox3.Value), Month(TextBox3.Value) + 1, 0), "dd/mm/yyyy")
 
.TextBox2 = Format(CDate(Application.WorksheetFunction.EoMonth(.TextBox3.Value, 0)), "dd/mm/yyyy")

but this macro show 30/11/2021 date instead of date show is 31/08/2021
Bad logic as according to VBA help - a must read at kid level ! - the correct codeline should be​
TextBox2.Value = Format(Application.EoMonth(CDate(TextBox3.Value), 0), "dd/mm/yyyy") if the computer date setting is like dd/mm/yyyy …​
 
Back
Top