According to the Microsoft website, the Range object has a property called Worksheet.
1. How do you use this?
2. How is this possible when a range is a "subset" of a Worksheet?
According to the Microsoft website, the Range object has a property called Worksheet.
1. How do you use this?
2. How is this possible when a range is a "subset" of a Worksheet?
Excel_vba,
See here for details and examples:
http://msdn.microsoft.com/en-us/libr.../ff837845.aspx
Hope that helps,
~tigeravatar
Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble
Thank you Tiger. You can obtain the worksheet name by doing something like:
Msgbox Worksheets(1).Name
1. So I not sure why there would be a need to have a Range object before Worksheets(1).Name?
2. I also this anyway with a Range:
MsgBox Range("A1:A10").Worksheet.Name
The Message returned was the name of sheet 1, which was "Andre." However, when I selected sheet 2 (which I named Larry), I still got "Andre" as the name returned even though sheet 2 (Larry) was the active sheet. Why does the code in the line above always return the name of sheet 1?
Hi,
Are you sure? Because when I selected sheet2, it returned the name of sheet2.The Message returned was the name of sheet 1, which was "Andre." However, when I selected sheet 2 (which I named Larry), I still got "Andre" as the name returned even though sheet 2 (Larry) was the active sheet. Why does the code in the line above always return the name of sheet 1?
Code I used :
With that being said, I don't see a good reason to use this property...![]()
Sub toto() Dim rg As Range, rg2 As Range Set rg = ActiveCell Set rg2 = Range("A1:A10") Debug.Print rg.Worksheet.Name Debug.Print rg2.Worksheet.Name End Sub
GC Excel
If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks