View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jeff[_42_] Jeff[_42_] is offline
external usenet poster
 
Posts: 8
Default peculiar error with Range() object

Try out the following code. If sheet2 is active, all 3 procedures work fine, but if sheet2 is not
active, TestRangeCells will not work but the other 2 procedures work fine. Anyone know why there is
a difference?

Sub TestRangeA1()
Sheets(2).Range("a1:a2") = 99
End Sub

Sub TestRangeCells()
Sheets(2).Range(Cells(1, 1), Cells(2, 1)) = 99
End Sub

Sub TestCells()
Sheets(2).Cells(1, 1) = 99
Sheets(2).Cells(2, 1) = 99
End Sub