View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
loyso loyso is offline
external usenet poster
 
Posts: 3
Default Excel VBA: Worksheet cell .Text property: 1024 bytes text len limit


This may illustrate loyso's problem:


Thank you, friends! I've found the problem.
The following repro illustrates my issue:

Option Explicit
Sub test()
Dim s As String
Dim i As Long
Const SomeText As String = "This text is 32 characters long "
Dim myCell As Range

Set myCell = ActiveSheet.Range("a1")

s = SomeText
For i = 1 To 1000
s = s & SomeText
Next

Debug.Print "Original length: " & Len(s)

ActiveSheet.Cells(1, 1).Value = s

s = ""
s = ActiveSheet.Cells(1, 1).Text

With ActiveSheet.Cells(1, 1)
Debug.Print "Value length: " & Len(myCell.Value)
Debug.Print "Text Length: " & Len(myCell.Text)
End With

End Sub

Output:
Original length: 32032
Value length: 32032
Text Length: 1024

Resolution: I'm using .Value everywhere instead of .Text and all is ok.

--
Alexei Baskakov