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

D

Daniel

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
 
S

ShaneDevenshire

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.
 
J

Jon Peltier

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
 
S

ShaneDevenshire

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top