Home |
Search |
Today's Posts |
#11
Posted to microsoft.public.excel.programming
|
|||
|
|||
Need help with adding a range name
Sorry, I meant to type single quotes.
"Dave Peterson" wrote in message ... That's a good way to fix the apostrophes in the worksheet name--not the spaces. (But it's a good fix!) - wrote: Or the modified version to capture single spaces in the sheet: .name = "'" & Replace(sheet2name,"'","''") & "'!database "Dave Peterson" wrote in message ... If there are no gaps in columns or rows, you could try this: with worksheets(Sheet2Name) .cells(sheet2firstrownum,1).currentregion.name _ = "'" & .name & "'!database" end with In any case, if you want to make the name local (a sheet level name), you'll want to add something like: .name = "'" & worksheets(sheet2name).name & "'!database or maybe just: .name = "'" & sheet2name & "'!database if sheet2name is really the name of the sheet. Bob wrote: I select a range by using the following code: Worksheets(Sheet2Name).Cells(Sheet2FirstRowNum, 1).Select Range(Selection, Selection.End(xlDown)).Select Range(Selection, Selection.End(xlToRight)).Select Is there a way I can "convert" the aforementioned selected range (which can vary) into the required R1C1 format so that I end up with something like this: ActiveWorkbook.Names.Add Name:="Database", RefersToR1C1:= _ "=Worksheets(Sheet2Name)!R2C1:R18C11" Any help would be greatly appreciated. Thanks. -- Dave Peterson -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Adding a range | Excel Discussion (Misc queries) | |||
Adding a Range | Excel Worksheet Functions | |||
Adding named range gives error "method range of object _Global failed " | Excel Programming | |||
adding reference-to-range control to excel range | Excel Programming | |||
sheets.range and adding cells that are out of the range | Excel Programming |