A Aaron Queenan Jan 20, 2004 #1 Is there any way, using the Excel Object Model, to find out which Workbook a Range belongs to? Thanks, Aaron Queenan.
Is there any way, using the Excel Object Model, to find out which Workbook a Range belongs to? Thanks, Aaron Queenan.
K Kevin Beckham Jan 20, 2004 #2 Use range.workbook, e.g. Dim c as range Set c = activecell msgbox c.workbook.name Kevin Beckham
A Aaron Queenan Jan 20, 2004 #3 Alas, I'm using Excel 2002 (aka XP), and its Range object doesn't have a Workbook property - only a Worksheet property. Also the Worksheet doesn't to have a Workbook property. Any other ideas? Thanks, Aaron.
Alas, I'm using Excel 2002 (aka XP), and its Range object doesn't have a Workbook property - only a Worksheet property. Also the Worksheet doesn't to have a Workbook property. Any other ideas? Thanks, Aaron.
A Aaron Queenan Jan 20, 2004 #4 It would appear that the Parent property of the Worksheet object returns the Workbook. Thanks, Aaron.
It would appear that the Parent property of the Worksheet object returns the Workbook. Thanks, Aaron.
C Chip Pearson Jan 20, 2004 #5 Aaron, Use the Parent property twice. The Parent of a Range is a Worksheet, and the Parent of a Worksheet is the Workbook. For example, Dim Rng As Range Dim WB As Workbook Set Rng = Range("A1") Set WB = Rng.Parent.Parent Debug.Print WB.Name -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com
Aaron, Use the Parent property twice. The Parent of a Range is a Worksheet, and the Parent of a Worksheet is the Workbook. For example, Dim Rng As Range Dim WB As Workbook Set Rng = Range("A1") Set WB = Rng.Parent.Parent Debug.Print WB.Name -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com