Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Setting Range Name using R1C1
I am trying to set a range name using the R1C1 format. Here is what I have
tried Dim MyRangeName as Range Set MyRangeName = Workbooks("Workbook1").Sheets("Sheet1").Range(Cell s(12, 12), Cells(15, 12)) The above line produces the following error: "Application-defined or Object-defined error". What I find strange is the above macro works fine if I replace the above with: Set MyRangeName = Workbooks("Workbook1").Sheets("Sheet1").Range("L12 :L15") For reasons that I believe are not relevant, I need to use the R1C1 method. Any suggestions would be much appreciated. -- needVBAhelp |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Setting Range Name using R1C1
The code doesn't know which worksheet CELLS is locat on. Use this instead
with Workbooks("Workbook1").Sheets("Sheet1") Set MyRangeName = .Range(.Cells(12, 12), .Cells(15, 12)) end with Notice the dot I put in front of CELLS "needVBAhelp" wrote: I am trying to set a range name using the R1C1 format. Here is what I have tried Dim MyRangeName as Range Set MyRangeName = Workbooks("Workbook1").Sheets("Sheet1").Range(Cell s(12, 12), Cells(15, 12)) The above line produces the following error: "Application-defined or Object-defined error". What I find strange is the above macro works fine if I replace the above with: Set MyRangeName = Workbooks("Workbook1").Sheets("Sheet1").Range("L12 :L15") For reasons that I believe are not relevant, I need to use the R1C1 method. Any suggestions would be much appreciated. -- needVBAhelp |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Setting Range Name using R1C1
Joel,
Worked great!! Thanks so much!!! -- needVBAhelp "Joel" wrote: The code doesn't know which worksheet CELLS is locat on. Use this instead with Workbooks("Workbook1").Sheets("Sheet1") Set MyRangeName = .Range(.Cells(12, 12), .Cells(15, 12)) end with Notice the dot I put in front of CELLS "needVBAhelp" wrote: I am trying to set a range name using the R1C1 format. Here is what I have tried Dim MyRangeName as Range Set MyRangeName = Workbooks("Workbook1").Sheets("Sheet1").Range(Cell s(12, 12), Cells(15, 12)) The above line produces the following error: "Application-defined or Object-defined error". What I find strange is the above macro works fine if I replace the above with: Set MyRangeName = Workbooks("Workbook1").Sheets("Sheet1").Range("L12 :L15") For reasons that I believe are not relevant, I need to use the R1C1 method. Any suggestions would be much appreciated. -- needVBAhelp |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
R1C1 - how can I permanently undo this setting in Excel? | Setting up and Configuration of Excel | |||
Discontinuous Range via VBA using R1C1? | Excel Programming | |||
Using R1C1 in VB to select a range | Excel Programming | |||
Select Range using R1C1 | Excel Programming | |||
R1C1 to Range | Excel Programming |