I am trying to store a range A3 to ZZ to last row in an array
lr variable equals to 500
Code: Select all
arr=Sheets("data").Range("A3:ZZ" & lr).Value
But I got overflow ...
Why did I get this error and how to fix that ??
Code: Select all
arr=Sheets("data").Range("A3:ZZ" & lr).Value
Code: Select all
Arr() = WS.Sheets("data").Range("A3:ZZ" & lr).Value2
WS.Sheets("data").Range("A3:ZZ" & lr).Copy ' This puts data in Excel, Windows, and office Clipboard
Stop
Rem 1 ' an object called the DataObject provides support for working with text strings on the Windows clipboard.
'Dim DtaObj As MSForms.DataObject ' Early Binding: RefMSFORMS.JPG : https://imgur.com/8zKpyr2
' Set DtaObj = New MSForms.DataObject
Dim LaterDtaObj As Object
Set LaterDtaObj = CreateObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
LaterDtaObj.GetFromClipboard ' We should have data in Windows clipboard
Dim strGet As String: Let strGet = LaterDtaObj.GetText() ' This is "A1" & vbTab & "B1" & vbTab & "C1"& vbCr & vbLf & "A2" & vbTab & "B2" .......
Rem 2 determine array size
Dim Rws() As String: Let Rws() = Split(strGet, vbCr & vbLf, -1, vbBinaryCompare) ' Split by vbCr & vbLf
Dim LBndRws As Long, UBndRws As Long: Let LBndRws = LBound(Rws()): Let UBndRws = UBound(Rws())
Dim Clms() As String: Let Clms() = Split(Rws(0), vbTab, -1, vbBinaryCompare) ' Split by & vbTab
Dim LBndClms As Long, UBndClms As Long: Let LBndClms = LBound(Clms()): Let UBndClms = UBound(Clms())
Dim arrStr() As String
ReDim arrStr(1 To UBndRws + 1, 1 To UBndClms + 1)
Rem 3 Fill Array
Dim CntClms As Long, CntRws As Long
For CntRws = 1 To UBndRws + 1 - 1 ' CntRws 1 2 3 ..... ' ( -1 -- Last " " I do not want !! )
Let Clms() = Split(Rws(CntRws - 1), vbTab, -1, vbBinaryCompare) ' Split by & vbTab
For CntClms = 1 To UBndClms + 1 ' CntClms 1 2 3 .....
Let arrStr(CntRws, CntClms) = Clms(CntClms - 1)
Next CntClms
Next CntRws
End Sub
Code: Select all
? arrStr(128,5)
###############################################################################################################################################################################################################################################################
? len(arrStr(128,5))
255
A few days ago I stumbled on these things https://social.msdn.microsoft.com/Forum ... rum=isvvba" onclick="window.open(this.href);return false;rory wrote:..serious issues with DataObject .. Windows 8 and later if you have an Explorer window open. That's why I prefer to use API calls if just putting text into the clipboard.