Solved

How do I construct a date in Excel VBA from a shortened month name ?

Posted on 2014-07-25
4
155 Views
Last Modified: 2014-07-25
Hi Experts,

I have an Excel sheet in which dates are split out across 3 columns. For example, I have 01 in column A, "Sep" in column B and 2013 in column C.

I want to create a formatted date (dd/mm/yyyy) in column D. How do I do this in VBA (I can do it manually entering a formula) ?

Thanks
Toco
0
Comment
Question by:Tocogroup
  • 2
4 Comments
 
LVL 21

Expert Comment

by:Randy Poole
ID: 40219163
which formula are you using?
0
 
LVL 13

Accepted Solution

by:
duncanb7 earned 500 total points
ID: 40219167
You can try this
Duncan
Sub test()
Sheets(1).Select
With ActiveSheet
.Range("D1").NumberFormat = "dd/mm/yyyy"
.Range("D1").Value = .Range("A1") &. Range("B1") & .Range("C1")
End With
End Sub

Open in new window

0
 

Author Closing Comment

by:Tocogroup
ID: 40219199
Many thanks. That works fine.

To answer the previous expert's question I used =DATEVALUE(1&"/"&MONTH(C2&1)&"/"&B2) as a formula within the sheet. No doubt this can be adapted to a VBA solution.
0
 
LVL 13

Expert Comment

by:duncanb7
ID: 40219205
Thanks for your points

Have a nice day

Duncan
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now