View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
SP[_5_] SP[_5_] is offline
external usenet poster
 
Posts: 10
Default Range error when referencing non active worksheet

I get an error in this Subroutine at the line marked , it works fine
if I activate the worksheet first and remove the "Worksheets(1)." from
the code.

Option Explicit
Dim Rng As Range
Dim Rw As Long

Private Sub UserForm_Activate()
Rw = Worksheets(1).Range("A65536").End(xlUp).Row
Set Rng = Worksheets(1).Range(Cells(2, 2), Cells(Rw, 2))

ComboBox1.RowSource = Rng.Address
End Sub

Any idea why this is happening ?

Thanks
Sal