Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default UDF Can't return more than 255 chars???

in the below code, both UDFs work if NUM_CHARS=100, but
the first one fails and the 2nd one succeeds if NUM_CHARS=1000.

The critical limit turns out to be 255. How do i make UDFs that return
arrays (with mixed string/date/double data) with strings that have more
than 255 chars? Is the only way to truncate all the strings to 255
chars?


Private Const NUM_CHARS As Long = 100

Public Function HOHO() As Variant
Dim v
ReDim v(0, 0) As Variant
v(0, 0) = String$(NUM_CHARS, "a")
HOHO = v
End Function

Public Function HOHO2() As Variant
Dim v As Variant
v = String$(NUM_CHARS, "a")

HOHO2 = v
End Function

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default UDF Can't return more than 255 chars???

On 30 Jun 2006 09:53:06 -0700, "R Avery" wrote:

Private Const NUM_CHARS As Long = 100

Public Function HOHO() As Variant
Dim v
ReDim v(0, 0) As Variant
v(0, 0) = String$(NUM_CHARS, "a")
HOHO = v
End Function

Public Function HOHO2() As Variant
Dim v As Variant
v = String$(NUM_CHARS, "a")

HOHO2 = v
End Function


If you specify the member of the array, it seems to work OK.

In other words, in function1:

HOHO = v(0,0)


--ron
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default UDF Can't return more than 255 chars???

I agree that if i specify the member, then it works, but that is not my
intent. the problem is not returning a single value but rather
returning an array. My real application returns an array with multiple
members, i just chose to use the single-item array for illustration
purposes.

If you specify the member of the array, it seems to work OK.

In other words, in function1:

HOHO = v(0,0)


--ron


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default UDF Can't return more than 255 chars???

On 30 Jun 2006 10:50:23 -0700, "R Avery" wrote:

I agree that if i specify the member, then it works, but that is not my
intent. the problem is not returning a single value but rather
returning an array. My real application returns an array with multiple
members, i just chose to use the single-item array for illustration
purposes.

If you specify the member of the array, it seems to work OK.

In other words, in function1:

HOHO = v(0,0)


--ron


I seem to recall Harlan Grove writing about some obscure limitations that Excel
has in handling strings 255 characters under certain circumstances. It is
clear that, within the UDF, HOHO does, indeed, contain the long string.

Perhaps you could use a Sub to assign elements of the array to various cells.
Or perhaps someone else has a proper solution.
--ron
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
How to truncate list of meaningful words greater than 15 chars tomeaningful words of 8 chars. Babloo Excel Worksheet Functions 4 April 29th 11 11:27 PM
sum first 2 chars if 3rd is something... [email protected] Excel Discussion (Misc queries) 13 September 29th 06 02:30 PM
determine if ea value in a col has more than 20 chars pmms Excel Discussion (Misc queries) 2 March 16th 06 03:11 PM
Removing last three chars teresa Excel Programming 3 January 24th 05 12:29 AM
Validation by counted chars KHW Excel Programming 0 September 12th 03 07:31 PM


All times are GMT +1. The time now is 09:15 AM.

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"