Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Delete all Characters "except"

Hi All.........

I don't remember where I got this code, or if it ever worked,....but I need
it now to delete all the characters in a cell except the ones indicated
not...........
I'm pasting it into a regular module and putting =KillText(A1) in cell B1
and all I get is #VALUE!

Can anybody see what I'm doing wrong please?........or have a better
suggestion?

Function KillText(cellinput) As String
Set cellinput = Intersect(cellinput.Parent.UsedRange, cellinput)
For i = 1 To Len(cellinput)
Select Case Mid(cellinput, i, 1)
Case 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, " ", "-", "/","%"
charval = Mid(cellinput, i, 1)
Case Else
charval = ""
End Select
KillText = KillText & charval
Next i
End Function

TIA
Vaya con Dios,
Chuck, CABGx3


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Delete all Characters "except"

Function KillText(cellinput) As String
Set cellinput = cellinput(1)
CharVal = ""
For i = 1 To Len(cellinput)
Select Case Mid(cellinput, i, 1)
Case 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, " ", "-", "/", "%"
CharVal = CharVal & Mid(cellinput, i, 1)
End Select
Next i
KillText = CharVal
End Function


worked for me.

--
Regards,
Tom Ogilvy

"CLR" wrote in message
...
Hi All.........

I don't remember where I got this code, or if it ever worked,....but I

need
it now to delete all the characters in a cell except the ones indicated
not...........
I'm pasting it into a regular module and putting =KillText(A1) in cell B1
and all I get is #VALUE!

Can anybody see what I'm doing wrong please?........or have a better
suggestion?

Function KillText(cellinput) As String
Set cellinput = Intersect(cellinput.Parent.UsedRange, cellinput)
For i = 1 To Len(cellinput)
Select Case Mid(cellinput, i, 1)
Case 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, " ", "-", "/","%"
charval = Mid(cellinput, i, 1)
Case Else
charval = ""
End Select
KillText = KillText & charval
Next i
End Function

TIA
Vaya con Dios,
Chuck, CABGx3




  #3   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 594
Default Delete all Characters "except"

Thank you kind Sir..........your version works beautifully for me
too.........

Vaya con Dios,
Chuck, CABGx3


"Tom Ogilvy" wrote in message
...
Function KillText(cellinput) As String
Set cellinput = cellinput(1)
CharVal = ""
For i = 1 To Len(cellinput)
Select Case Mid(cellinput, i, 1)
Case 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, " ", "-", "/", "%"
CharVal = CharVal & Mid(cellinput, i, 1)
End Select
Next i
KillText = CharVal
End Function


worked for me.

--
Regards,
Tom Ogilvy

"CLR" wrote in message
...
Hi All.........

I don't remember where I got this code, or if it ever worked,....but I

need
it now to delete all the characters in a cell except the ones indicated
not...........
I'm pasting it into a regular module and putting =KillText(A1) in cell

B1
and all I get is #VALUE!

Can anybody see what I'm doing wrong please?........or have a better
suggestion?

Function KillText(cellinput) As String
Set cellinput = Intersect(cellinput.Parent.UsedRange, cellinput)
For i = 1 To Len(cellinput)
Select Case Mid(cellinput, i, 1)
Case 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, " ", "-", "/","%"
charval = Mid(cellinput, i, 1)
Case Else
charval = ""
End Select
KillText = KillText & charval
Next i
End Function

TIA
Vaya con Dios,
Chuck, CABGx3






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
is there a way to delete all characters to the right of a ":"? [email protected] Excel Discussion (Misc queries) 4 May 11th 23 11:47 AM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Excel "Move or Copy" and "Delete" sheet functions dsiama Excel Worksheet Functions 1 December 28th 07 01:57 PM
Adding "New" "Insert" "Delete" into a workbook to change from data 1 to data 2 etc Bob Reynolds[_2_] Excel Programming 0 March 4th 04 08:52 PM
Delete characters up to ":" Dave Peterson[_3_] Excel Programming 3 February 2nd 04 07:46 PM


All times are GMT +1. The time now is 04:31 PM.

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"