Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default String Not Longer Than 255 Characters in VBA?

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 280
Default String Not Longer Than 255 Characters in VBA?

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"

"Quido" wrote in message
...
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




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
Insert Leading Characters If String Is Only 7 Characters Paperback Writer Excel Discussion (Misc queries) 2 April 21st 09 09:07 PM
Count characters within a string Francisco Excel Worksheet Functions 4 April 10th 07 05:28 PM
Sumif text is contained winthin a longer text string in a cell Johnny M[_2_] Excel Worksheet Functions 3 March 21st 07 02:50 PM
Binary Numbers longer than 10 characters Andibevan Excel Worksheet Functions 2 April 6th 05 10:08 PM
frequency of characters within a string Nick Excel Programming 4 July 24th 03 07:52 PM


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