Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I use networkdays for my calculation...The 2 cells that the dates are
pulled from are set like such; From: Monday, May 8,2006 and Through: Wednesday, May 10, 2006. How would I go about removing the commas, colons, from, through and day in VBA? Thanks, Hans |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Assuming the From and Through cells are *always* in the format
From colon space weekday comma space month space daynumber comma space year and Through colon space weekday comma space month space daynumber comma space year ....then this code will convert the textual dates within those cells into Excel-readable dates. Sub test() Dim From As Date, Thru As Date From = DateValue(Mid(Range("a1").Value, InStr(1, Range("a1").Value, ", ") + 1, Len(Range("a1").Value))) Thru = DateValue(Mid(Range("b1").Value, InStr(1, Range("b1").Value, ", ") + 1, Len(Range("b1").Value))) End Sub This code works by ignoring the From: , Through: , and weekday name, and converting the remainder of the string into a date using the DateValue function in VBA. |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Dave,
When I ran this I got a Type mismatch error...what I put in was this; Sub test() Dim ClassBreakdownByStore As Workbook Dim From As Date, Thru As Date From = DateValue(Mid(Range("B1").Value, InStr(1, Range("B1").Value, ",") + 1, Len(Range("B1").Value))) Thru = DateValue(Mid(Range("b1").Value, InStr(1, Range("b1").Value, ",") + 1, Len(Range("b1").Value))) End Sub I am not understanding this somewhere that is why I am called a "newbie" at this! Thanks Hans |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
if data in one cell, then date in adjacent cell | Excel Worksheet Functions | |||
Removing a blank cell between data | New Users to Excel | |||
Removing data from cell within an excel spreadsheet | Excel Discussion (Misc queries) | |||
Last cell of data in a column | Excel Discussion (Misc queries) | |||
Help PLEASE! Not sure what answer is: Match? Index? Other? | Excel Worksheet Functions |