Set RN = Range(Cells(2, 1), Cells(r, 1)) error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What wrong with this. It create error. How can I improve to get rid the
error?

Set RN = Range(Cells(2, 1), Cells(r, 1))

Thanks
Daniel
 
Hi Daniel,

Too much missing information - has r been declared and what data type is it
and what value does it have. What property of the range are you trying to
store in the variable RN? What type of variable is RN and has it been
declared.
 
Make sure variables are declared and defined, and make sure you reference
potentially indeterminate ranges.

Dim RN As Range
Dim wks As Worksheet
Dim r As Long

Set wks = ActiveWorkbook.Worksheets("My Sheet")
r = 100

Set RN = wks.Range(wks.Cells(2,1), wks.Cells(r, 1))

- Jon
 
Hi,

The reason Jon and I are pointing these issues out is that your single line
of code is fine. The reason it fails is something else is wrong and Jon and
I can't see your code so we are just suggesting the most likely places.

Fact is, code that fails on a particular line can fail despite the fact that
the line is correct.
 
Back
Top