1. Welcome to Chandoo.org Forums. Short message for you

    Hi Guest,

    Thanks for joining Chandoo.org forums. We are here to make you awesome in Excel. Before you post your first question, please read this short introduction guide. When posting or responding to questions please remember our values at Chandoo.org are: Humility, Passion, Fun, Awesomeness, Simplicity, Sharing Remember that we have people here for whom English is not there first language and we need to allow for this in our dealings.

    Yours,
    Chandoo
  2. 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...

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

How to Get only first Date of a month in Text box .

Discussion in 'VBA Macros' started by Mohammad Ishaq, Jan 9, 2019.

  1. Mohammad Ishaq

    Mohammad Ishaq Member

    Messages:
    47
    Hello,

    I have a user form having one text box and a button.I want that when i click on the button,i get only first date of the current month .

    For example today is Jan 9 2019,i want to get only Jan 01 2019 instead of Jan 9 2019.

    Attached Files:

  2. YasserKhalil

    YasserKhalil Well-Known Member

    Messages:
    1,016
    Try this code
    Code (vb):
    Private Sub CommandButton1_Click()
        TextBox1.Value = Format(DateSerial(Year(Date), Month(Date), 1), "mmm dd yyyy")
    End Sub
    Mohammad Ishaq likes this.
  3. Mohammad Ishaq

    Mohammad Ishaq Member

    Messages:
    47
    Thanks
  4. Deepak

    Deepak Excel Ninja

    Messages:
    2,882
    A Native approach.

    Code (vb):
        TextBox1.Value = Format(1 + Application.EoMonth(Date, -1), "mmm dd yyyy")
    Mohammad Ishaq and YasserKhalil like this.

Share This Page