Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I enter formula sum(range+range)*0.15 sumif(range=3) | Excel Discussion (Misc queries) | |||
Cond. Format Data Bars of range based on values of another range | Excel Worksheet Functions | |||
Excel Addin:Setting the range to the Excel.Range object range prop | Excel Worksheet Functions | |||
Selecting range in list of range names depending on a cell informa | Excel Discussion (Misc queries) | |||
how to? set my range= my UDF argument (range vs. value in range) [advanced?] | Excel Programming |