title: run time error 1004 when trying to select a rectangle range of values
body: <p>I wonder if anyone knows how to select a rectangle range of values? This range will not be fixed. For this particular example, it will select B5 - G7 in a rectangle form and then it will set a condition format to add in some colors.</p>
  
  <p>I have attempted the codebut it is giving me an error at this portion</p>
  
  <pre><code>ActiveSheet.Cells(colorrow &amp; "2", _
  ActiveSheet.Cells(colorrow &amp; "2").End(xlDown).End(xlToRight)).Select
  </code></pre>
  
  <p>wonder if anyone know why? will be thankful!</p>
  
  <p><img src="https://i.stack.imgur.com/ExdQd.png" alt="enter image description here"></p>
  
  <p>I have attempted writing out some coding.</p>
  
  <p>My code is as follows:</p>
  
  <pre><code>Sub Macro2()
  
   Dim thevaluestocopy As Variant, colorCell as Range, colorrow as Long, thefirstcolorrow as Long
  
   colorrow = 1
  
  Do
  
  Set colorCell = Sheets("Sheet1").Cells(colorrow, 1)
  'check for test1-test6 if its around do nothing, else goes to the next row and next column
  If colorCell = "test1" Or colorCell = "test2" Or colorCell = "test3" _
  Or colorCell = "test4" Or colorCell = "test5" Or colorCell = "test6" _ Then 
  'Do nothing
  Else
  thefirstcolorrow = Sheets("Sheet1").Cells(colorrow, 2)
  'This statement gives me the error.. not sure why it cant work 
  ActiveSheet.Cells(colorrow &amp; "2", _
  ActiveSheet.Cells(colorrow &amp; "2").End(xlDown).End(xlToRight)).Select
  Exit Do
  End If
  colorrow = colorrow + 1
  Loop
  
  
  'add colors into cell
  ActiveCell.Select
  Selection.FormatConditions.AddColorScale ColorScaleType:=3
  Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
  Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _
      xlConditionValueLowestValue
  With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor
      .Color = 8109667
  End With
  Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _
      xlConditionValuePercentile
  Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50
  With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor
      .Color = 8711167
  End With
  Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _
      xlConditionValueHighestValue
  With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor
      .Color = 7039480
  End With
  
  End Sub
  </code></pre>