Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default len limit of 255 of function. any workaround?

I am getting a VALUE error when I run this function and the input string is
longer than 255.
Basicaly, I am wanting to strip out all control characters.

Is there a better way to do that?
TIA,
Mc



Public Function CleanKey(vData As String) As String
Dim nChar As Long
Dim sChar As String * 1
Dim nCharCode As Long
Dim sNewData As String


For nChar = 1 To Len(vData)
sChar = Mid$(vData, nChar, 1)
nCharCode = Asc(sChar)
If nCharCode <= Asc("~") And nCharCode = Asc(" ") _
Then sNewData = sNewData & sChar
Next nChar
CleanKey = sNewData
End Function



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default len limit of 255 of function. any workaround?

Hi
Could you use the CLEAN function?
Application.Worksheetfunctions.Clean(vData)

read the help as clean doesn't clean everything (you'll need to check
the nCharCode range of values you need).
regards
Paul

On Apr 17, 10:48 am, "Mctabish" wrote:
I am getting a VALUE error when I run this function and the input string is
longer than 255.
Basicaly, I am wanting to strip out all control characters.

Is there a better way to do that?
TIA,
Mc

Public Function CleanKey(vData As String) As String
Dim nChar As Long
Dim sChar As String * 1
Dim nCharCode As Long
Dim sNewData As String

For nChar = 1 To Len(vData)
sChar = Mid$(vData, nChar, 1)
nCharCode = Asc(sChar)
If nCharCode <= Asc("~") And nCharCode = Asc(" ") _
Then sNewData = sNewData & sChar
Next nChar
CleanKey = sNewData
End Function



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default len limit of 255 of function. any workaround?

I don't think it's your function that's having the trouble with the length of
the string.

Any chance you're retrieving a long string from a closed workbook, then trying
to clean that.

Excel will only bring back up to 255 characters from a closed workbook.

Mctabish wrote:

I am getting a VALUE error when I run this function and the input string is
longer than 255.
Basicaly, I am wanting to strip out all control characters.

Is there a better way to do that?
TIA,
Mc

Public Function CleanKey(vData As String) As String
Dim nChar As Long
Dim sChar As String * 1
Dim nCharCode As Long
Dim sNewData As String

For nChar = 1 To Len(vData)
sChar = Mid$(vData, nChar, 1)
nCharCode = Asc(sChar)
If nCharCode <= Asc("~") And nCharCode = Asc(" ") _
Then sNewData = sNewData & sChar
Next nChar
CleanKey = sNewData
End Function


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default len limit of 255 of function. any workaround?

Thanks! Thank did it!
Mc

wrote in message
oups.com...
Hi
Could you use the CLEAN function?
Application.Worksheetfunctions.Clean(vData)

read the help as clean doesn't clean everything (you'll need to check
the nCharCode range of values you need).
regards
Paul

On Apr 17, 10:48 am, "Mctabish" wrote:
I am getting a VALUE error when I run this function and the input string
is
longer than 255.
Basicaly, I am wanting to strip out all control characters.

Is there a better way to do that?
TIA,
Mc

Public Function CleanKey(vData As String) As String
Dim nChar As Long
Dim sChar As String * 1
Dim nCharCode As Long
Dim sNewData As String

For nChar = 1 To Len(vData)
sChar = Mid$(vData, nChar, 1)
nCharCode = Asc(sChar)
If nCharCode <= Asc("~") And nCharCode = Asc(" ") _
Then sNewData = sNewData & sChar
Next nChar
CleanKey = sNewData
End Function





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default len limit of 255 of function. any workaround?

Dave,

I am not calling for any closed wb.
clean() did do what I wanted though!

Thanks
Mc


"Dave Peterson" wrote in message
...
I don't think it's your function that's having the trouble with the length
of
the string.

Any chance you're retrieving a long string from a closed workbook, then
trying
to clean that.

Excel will only bring back up to 255 characters from a closed workbook.

Mctabish wrote:

I am getting a VALUE error when I run this function and the input string
is
longer than 255.
Basicaly, I am wanting to strip out all control characters.

Is there a better way to do that?
TIA,
Mc

Public Function CleanKey(vData As String) As String
Dim nChar As Long
Dim sChar As String * 1
Dim nCharCode As Long
Dim sNewData As String

For nChar = 1 To Len(vData)
sChar = Mid$(vData, nChar, 1)
nCharCode = Asc(sChar)
If nCharCode <= Asc("~") And nCharCode = Asc(" ") _
Then sNewData = sNewData & sChar
Next nChar
CleanKey = sNewData
End Function


--

Dave Peterson



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
Workaround for HYPERLINK argument length limit Dave Booker Excel Worksheet Functions 5 April 4th 23 02:22 PM
Excel text export limit - 1024 per line (not cell), workaround? Dave Excel Discussion (Misc queries) 11 August 11th 09 04:41 PM
Limit on logical function AJ[_4_] Excel Discussion (Misc queries) 4 October 29th 08 12:23 AM
busted workaround for 255 character limit in cells mklapp Excel Programming 3 July 11th 05 09:28 AM
IF Function Help due to 7 limit John F Excel Worksheet Functions 11 January 12th 05 10:07 PM


All times are GMT +1. The time now is 09:40 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"