+ Reply to Thread
Results 1 to 10 of 10

Dates to First Day of Month

  1. #1
    Forum Contributor
    Join Date
    12-18-2019
    Location
    chennai
    MS-Off Ver
    excel 2010
    Posts
    141

    Dates to First Day of Month

    I am having date in one column and next column i am applying formula =C10-DAY(C10)9+1 to find first date of month. This formula is working well however i want to automate this process through VBA.

    From Active selection of Column (Date Column) , one column to be inserted in right side and then the above formula to be applied. i will be selected entire column, the formula to be applied only for where its having dates. Some one please help me to provide VBA code for this.
    Attached Files Attached Files

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Dates to First Day of Month

    Hi, your file is clearly not macro embedded.
    the code you want in VBA is this

    let's assume that the date is in column A
    Please Login or Register  to view this content.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Contributor
    Join Date
    12-18-2019
    Location
    chennai
    MS-Off Ver
    excel 2010
    Posts
    141

    Re: Dates to First Day of Month

    Hi Keebellah.

    Thanks for your help.

    The date column is not fixed one. Some time it is A or B. Hence I mentioned selection of date column. Like if I have date in column H, then I will selection of column H, column I to be created and formula to be updated

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Dates to First Day of Month

    Then adapt the code for the corresponding column, the code remains the same (except for the column parameters)

  5. #5
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Dates to First Day of Month

    Try the below code … You don't need to select the whole column just select any cell in the column you need to run the macro from

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    12-18-2019
    Location
    chennai
    MS-Off Ver
    excel 2010
    Posts
    141

    Re: Dates to First Day of Month

    Hi NANKW83

    Thanks it's worked. Thanks for your help.

  7. #7
    Forum Contributor
    Join Date
    12-18-2019
    Location
    chennai
    MS-Off Ver
    excel 2010
    Posts
    141

    Re: Dates to First Day of Month

    Hi Nankw83

    on the result column, i want to change the date format as "MM-YY". i have added
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    but its not working. can you please help

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Dates to First Day of Month

    Format setting:

    Please Login or Register  to view this content.

  9. #9
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Dates to First Day of Month

    As Keebellah explained, you can incorporate the .NumberFormat as below in your code. In case you want this number format for the whole column instead of only the used range of the newly added column, delete the red section in the code

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    12-18-2019
    Location
    chennai
    MS-Off Ver
    excel 2010
    Posts
    141

    Re: Dates to First Day of Month

    Hi Nakw83

    Working as expected.....

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 16
    Last Post: 11-23-2019, 01:41 PM
  2. Replies: 1
    Last Post: 07-02-2017, 08:02 PM
  3. [SOLVED] Calculation of days per month for dates beginning in one month and ending in another month
    By Fahrettin in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-07-2015, 04:52 PM
  4. [SOLVED] Is there a way to insert all dates for a month weekly when user inputs Month and a Year?
    By uniqbboy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-11-2014, 10:40 AM
  5. find time left in month.days unit between two dates(in YEAR.MONTH.DAY)
    By xcfeng95 in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 02-21-2014, 12:55 PM
  6. Date Formula for days of the month, new dates starting on the 2nd of the month.
    By Kenn Jerger in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-04-2013, 01:31 AM
  7. Replies: 2
    Last Post: 12-01-2012, 03:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1