Range help

  • Thread starter Thread starter Ray Batig
  • Start date Start date
R

Ray Batig

I have a named range on a worksheet. The macro would add a new entry to the
next cell in the row. I can get this part OK. I have found an instance, say
when I first use the worksheet, when the named range is only 1 cell long
and the cell will be empty. Before I add a new column, I want to fill the
first cell if it is empty.

This is the code, however, I get an error message that the object doesn't
support this property. What do you suggest to fix this? Is there a better
way to do this?

row = Range ("MyRange").Cell(0,1).Row

If Range ("MyRange").Count = 1 And Range ("MyRange").Cell(0,1).Value = ""
Then

col = Range ("MyRange").Cell(0,1).Column
Else

col =
Worksheets("MySheet").Cells(row,256).End(xlToLeft).Offset(0,1).Column
End If

Thanks in advance for your help!

Ray
 
Ray,

Instead of Range ("MyRange").Count
Try: Range("MyRange").Cells.Count

You could be confusing Offset with Cells.

Instead of .Cell(0,1)
Try: .Cells(1,1)


Rob
 
Rob,

Thanks. I had to replace Cell with Cells in the first three lines. A little
bit of confusion was cleared up by your eyes.

Cheers
 
Back
Top