Getting around the Max String size in a vba function?

前端 未结 6 1327
北海茫月
北海茫月 2020-11-28 15:57

The max number of characters you can use in string in a vba function is 255. I am trying to run this function

Var1= 1
Var2= 2
.
.
.
Var256 =256

RunMacros=          


        
6条回答
  •  生来不讨喜
    2020-11-28 16:08

    I may have missed something here, but why can't you just declare your string with the desired size? For example, in my VBA code I often use something like:

    Dim AString As String * 1024
    

    which provides for a 1k string. Obviously, you can use whatever declaration you like within the larger limits of Excel and available memory etc.

    This may be a little inefficient in some cases, and you will probably wish to use Trim(AString) like constructs to obviate any superfluous trailing blanks. Still, it easily exceeds 256 chars.

提交回复
热议问题