Change month into date

Panoos64

Well-known Member
Joined
Mar 1, 2014
Messages
890
Hi all, Kindly require to provide me support so that to create a VBA code, by which should change in col. "A" the format of mm/yyyy into dd/mm/yyyy.

e.g. 09/2018 should be 30/09/2018
10/2018 should be 31/10/2018

Thank you all in advance
 
Last edited:

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Try this

Code:
Option Explicit
Dim LastRowNo As Long
Dim DayLoop As Long


Sub DaysInMonth()
LastRowNo = Sheets(1).Range("A1048576").End(xlUp).Row


For DayLoop = 1 To LastRowNo
    Sheets(1).Range("B" & DayLoop).Value = Format(Day(DateSerial(Year(Sheets(1).Range("A" & DayLoop).Value), Month(Sheets(1).Range("A" & DayLoop).Value) + 1, 1) - 1) & "/" & Month(Sheets(1).Range("A" & DayLoop).Value) & "/" & Year(Sheets(1).Range("A" & DayLoop).Value), "dd/mm/yyyy")
    
Next DayLoop


End Sub
 
Last edited:
Upvote 0
Hi nemm, your code works perfect and based to my data! many thanks for your support. Hv a nice day
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,182
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top