title: Row selection limit (?) VBA excel
body: <p>I am new in VBA.</p>
  
  <p>I run into a problem and I could not find any answer using google. The goal is: selecting multiple rows, then deleting them. Here is the code:</p>
  
  <pre><code>Dim i As Long
  Dim SelectedCells As String
  
  i = 1
  SelectedCells = ""
  
  While IsEmpty(Range("A" &amp; i)) = False
  
  If Range("A" &amp; i) &lt; 5 Then
  
          SelectedCells = SelectedCells &amp; i &amp; ":" &amp; i &amp; ","
          i = i + 1
  Else:
          i = i + 1
  End If
  
  Wend
  
  SelectedCells = Left(SelectedCells, Len(SelectedCells) - 1)
  'That is how I inspected the value of the "SelectedCells" variable:
  'Range("AA1").Value = Right(SelectedCells, 25)
  Range(SelectedCells).Select
  Selection.Delete Shift:=xlUp
  </code></pre>
  
  <p>It works fine up to 45 selections. If it needs to select more than that, it returns an error message at the "Range(SelectedCells).Select":
  "Run-time error '1004':
  Method 'Range' of object '_Global' failed.</p>
  
  <p>However, I inspected the value of SelectedCells variable, and it looks as it should...</p>
  
  <p>Does anybody have an idea what is wrong? Do you have any better idea to solve this issue? I need to run this kind of loop on several thousands (or hundred-thousands) of records.</p>
  
  <p>Any input will be appriciated.</p>
  
  <p>Thank you.</p>