Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
 
Posts: n/a
Default removing date data from a cell

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   Report Post  
Posted to microsoft.public.excel.misc
Dave O
 
Posts: n/a
Default removing date data from a cell

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   Report Post  
Posted to microsoft.public.excel.misc
 
Posts: n/a
Default removing date data from a cell

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
if data in one cell, then date in adjacent cell Jane Excel Worksheet Functions 8 December 22nd 07 03:34 AM
Removing a blank cell between data Bonnie, OH New Users to Excel 1 February 27th 06 08:07 PM
Removing data from cell within an excel spreadsheet Dawn Excel Discussion (Misc queries) 6 February 21st 06 05:16 PM
Last cell of data in a column LACA Excel Discussion (Misc queries) 1 January 17th 06 08:22 PM
Help PLEASE! Not sure what answer is: Match? Index? Other? baz Excel Worksheet Functions 7 September 3rd 05 03:47 PM


All times are GMT +1. The time now is 05:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"