I have:
Microsoft.Office.Interop.Excel.Workbook wb;
Microsoft.Office.Interop.Excel.Name name;
Is there any way to get the worksheet name that the named range is on in the given workbook, assuming I've gotten the named range's Name object and wb already?
Sheet name code Excel formula Step 1: Type “CELL(“filename”,A1)”. The cell function is used to get the full filename and path. This function returns the filename of . xls workbook, including the sheet name.
The easiest is using the reference window while working on an Excel worksheet. In the upper left portion of the Excel environment is a small box which contains the cell name of the selected cell. A1, C10, etc. Click inside this box and type in a name then hit enter.
We can use the CELL Function to return the file path, name, and sheet by inputting “filename”. To get the current worksheet's name, you can use the function with or without the optional reference argument, referring to any cell on the current tab.
Yes, use the Parent property to work your way up the object hierarchy:
ws = name.RefersToRange.Parent.name;
Range.Worksheet
is a self-documenting alternative to Range.Parent
:
string wsName = name.RefersToRange.Worksheet.Name;
(Or in 2 steps:
Microsoft.Office.Interop.Excel.Worksheet ws = name.RefersToRange.Worksheet;
string wsName = ws.Name;
)
Reference:
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.name.referstorange.aspx
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.range.worksheet.aspx
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel._worksheet.name(v=office.15).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With