Solved

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

Posted on 2014-07-25
4
154 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
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 in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

746 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

14 Experts available now in Live!

Get 1:1 Help Now