Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to strip dashes out of numbers in a variable


How do you strip out dashes, convert numers to a text string, & assign
it to a variable from the following?

monthendate=6-30-05

monthendname=monthendate (need the monthendname to be 63005)

Thank so very much.

mikeburg


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=387171

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default How to strip dashes out of numbers in a variable

mike (who apparently doesn't like capital letters)

Dim MonthEndDate As Date
Dim MonthEndName As String
MonthEndDate = DateValue("6-30-05")
MonthEndName = CStr(Format(MonthEndDate, "mdyy"))
MsgBox MonthEndName

HTH,
Bernie
MS Excel MVP


"mikeburg" wrote in message
...

How do you strip out dashes, convert numers to a text string, & assign
it to a variable from the following?

monthendate=6-30-05

monthendname=monthendate (need the monthendname to be 63005)

Thank so very much.

mikeburg


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=387171



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default How to strip dashes out of numbers in a variable



Bernie Deitrick wrote:
mike (who apparently doesn't like capital letters)

Dim MonthEndDate As Date
Dim MonthEndName As String
MonthEndDate = DateValue("6-30-05")
MonthEndName = CStr(Format(MonthEndDate, "mdyy"))
MsgBox MonthEndName

HTH,
Bernie
MS Excel MVP


I think I must be being pretty dumb, but doesn't Format return a
string? Why use CStr? Plus, CStr rather idioticaly adds a space to
the left of the string, so if you do need to use it, you should use:
MonthEndName = LTrim(CStr(Format(MonthEndDate, "mdyy")))

Iain

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How to strip dashes out of numbers in a variable

myVar = Application.Substitute("6-30-05","-","")

--

HTH

RP
(remove nothere from the email address if mailing direct)


"mikeburg" wrote in
message ...

How do you strip out dashes, convert numers to a text string, & assign
it to a variable from the following?

monthendate=6-30-05

monthendname=monthendate (need the monthendname to be 63005)

Thank so very much.

mikeburg


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile:

http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=387171



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default How to strip dashes out of numbers in a variable

You're right that I didn't need it - but CStr doesn't add a space:

Dim myVal As Long
myVal = 2314
MsgBox Len(myVal) = Len(CStr(myVal))

Could you post code that shows that it does?

HTH,
Bernie
MS Excel MVP


wrote in message oups.com...


Bernie Deitrick wrote:
mike (who apparently doesn't like capital letters)

Dim MonthEndDate As Date
Dim MonthEndName As String
MonthEndDate = DateValue("6-30-05")
MonthEndName = CStr(Format(MonthEndDate, "mdyy"))
MsgBox MonthEndName

HTH,
Bernie
MS Excel MVP


I think I must be being pretty dumb, but doesn't Format return a
string? Why use CStr? Plus, CStr rather idioticaly adds a space to
the left of the string, so if you do need to use it, you should use:
MonthEndName = LTrim(CStr(Format(MonthEndDate, "mdyy")))

Iain





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to strip dashes out of numbers in a variable


Thank you very much.

You all help a lot & I appreciate it!

mikeburg


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=387171

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default How to strip dashes out of numbers in a variable



Bernie Deitrick wrote:
You're right that I didn't need it - but CStr doesn't add a space:

Dim myVal As Long
myVal = 2314
MsgBox Len(myVal) = Len(CStr(myVal))

Could you post code that shows that it does?

HTH,
Bernie
MS Excel MVP


No, I was right the first time - I'm being pretty dumb. Str adds a
leading space, not CStr. My bad.

Iain

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
Need to change numbers with dashes to numbers with no dashes cheryltraining Excel Discussion (Misc queries) 3 November 3rd 09 06:23 PM
How do I strip just numbers from an alphanumeric cell? Benjamin Excel Worksheet Functions 6 October 6th 09 12:36 AM
removing dashes from numbers Pat Jones Excel Worksheet Functions 8 June 21st 07 08:44 PM
Convert phone numbers with dashes in them to just numbers J H Excel Discussion (Misc queries) 2 June 23rd 06 06:56 PM
Convert phone numbers with dashes in them to just numbers J H Excel Discussion (Misc queries) 2 June 23rd 06 02:40 AM


All times are GMT +1. The time now is 03:46 AM.

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

About Us

"It's about Microsoft Excel"