String Not Longer Than 255 Characters in VBA?

Q

Quido

Hello, I'd like to use a macro defining range names in a workbook. For the
purpose of creating the range formula, I make use of a string variable, like
this:
....
Dim RANGE As String

For Each ROW In ROWS
RANGE = RANGE & "MySheet!$" & COLUMN & "$" & ROW & ","
Next
.....

It seems to me there must be an overflow in the variable RANGE, since the
name is then not defined correctly if the ROWS array has more than say 20
elements.

MY QUESTION: Is a string variable in VBA limited to 255 characters? Or is
there any way to declare a string variable longer than that, by explicitly
stating its lenght, e.g. 500 characters?

Thanks in advance
 
B

Bob Kilmer

The limitation is the Range (that may vary with the version), not the VBA
variable. I can get 1024 characters in a cell in XL2002. This is well
discussed on this group. Check Google.

Recommend:
Assign using the value property: Range("A1").Value = "blah"
Read using the Text property: Range("A1").Value = Range("A1").Text & "blah"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top