#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Range help

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Range help

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


"Ray Batig" wrote in message
ink.net...
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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Range help

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
Rob van Gelder wrote in message
...
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


"Ray Batig" wrote in message
ink.net...
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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I enter formula sum(range+range)*0.15 sumif(range=3) tkw Excel Discussion (Misc queries) 2 October 1st 09 09:17 PM
Cond. Format Data Bars of range based on values of another range alexmo Excel Worksheet Functions 4 January 16th 09 04:03 AM
Excel Addin:Setting the range to the Excel.Range object range prop Rp007 Excel Worksheet Functions 5 November 24th 06 04:30 PM
Selecting range in list of range names depending on a cell informa Courreges Excel Discussion (Misc queries) 2 June 19th 06 10:59 AM
how to? set my range= my UDF argument (range vs. value in range) [advanced?] Keith R[_3_] Excel Programming 2 August 11th 03 05:55 PM


All times are GMT +1. The time now is 02:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"