how to convert yyyymm number string into end month date using vba?

Viewed 2183

Currently, in my Excel, there is a string of year and month written as yyyymm. Eg: 201706

Right now I would like to convert it into the end of month date in another worksheet. Eg: 20170630

The question now is, how do I tell Excel to auto create the day based on the month value in the string?

I was planning on using if statements to declare each month based on the ending value at the back of the string. (ie: If 201706 , date = 20170630)

But then I thought that won't work for February's leap year. Is there another method to use besides that?

4 Answers
Related