View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
smartnhandsome smartnhandsome is offline
external usenet poster
 
Posts: 11
Default Out of Memory Error 7 While assigning named range value

I trying all the things I could find, I finally was able to get rid of
the problem by splitting the long string into smaller strings and
putting them into another sheet and later putting those back into the
main named range.

Dim r As Range
Set r = Worksheets("rec").Range("A1")

Do While Not r = ""
r.ClearContents
Set r = r.Offset(1, 0)
Loop
Set r = Nothing
If Len(Terms) 5000 Then
copyRange (Terms)
Else
Worksheets("Input").Range("Terms") = Terms
End If



Function copyRange(textToCopy As String)
Dim tempString As String
Dim i As Integer
Dim j As Integer
For i = 1 To (Len(textToCopy) / 1024 + 1)
j = (i * 1025)
Worksheets("ref_rec").Cells(i, 1).Value = Mid(textToCopy, j - 1024,
1024)

Next i

Dim targetCell As Range
Dim r As Range
Set r = Worksheets("rec").Range("A1")
Set targetCell = Worksheets("Input").Range("Terms")
targetCell.Value = r.Value
Set r = Nothing
End Function