+ Reply to Thread
Results 1 to 4 of 4

Workbook Property or Method

  1. #1
    Gary''s Student
    Guest

    Workbook Property or Method

    How do I get the Workbook name associated with a range?

    Function whereisit(r As Range) As String
    MsgBox (r.Address)
    MsgBox (r.Worksheet.Name)
    whereisit = r.Address & r.Worksheet.Name
    End Function

    I need the workbook name as well as the Address and worksheet name.

    Thanks in advance
    --
    Gary''s Student

  2. #2
    Andy Pope
    Guest

    Re: Workbook Property or Method

    Hi,

    You can make use of the Parent property. The example show it's use on
    both the .Worksheet and Range object.

    Function whereisit(r As Range) As String
    MsgBox (r.Address)
    MsgBox (r.Worksheet.Name)
    MsgBox (r.Worksheet.Parent.Name)
    whereisit = r.Address & r.Worksheet.Name & r.Parent.Parent.Name
    End Function

    Cheers
    Andy

    Gary''s Student wrote:
    > How do I get the Workbook name associated with a range?
    >
    > Function whereisit(r As Range) As String
    > MsgBox (r.Address)
    > MsgBox (r.Worksheet.Name)
    > whereisit = r.Address & r.Worksheet.Name
    > End Function
    >
    > I need the workbook name as well as the Address and worksheet name.
    >
    > Thanks in advance


    --

    Andy Pope, Microsoft MVP - Excel
    http://www.andypope.info

  3. #3
    Norman Jones
    Guest

    Re: Workbook Property or Method

    Hi Gary,

    Try r.Parent.Parent.Name


    ---
    Regards,
    Norman



    "Gary''s Student" <[email protected]> wrote in message
    news:[email protected]...
    > How do I get the Workbook name associated with a range?
    >
    > Function whereisit(r As Range) As String
    > MsgBox (r.Address)
    > MsgBox (r.Worksheet.Name)
    > whereisit = r.Address & r.Worksheet.Name
    > End Function
    >
    > I need the workbook name as well as the Address and worksheet name.
    >
    > Thanks in advance
    > --
    > Gary''s Student




  4. #4
    Gary''s Student
    Guest

    Re: Workbook Property or Method

    Thank you both very much.
    --
    Gary''s Student


    "Norman Jones" wrote:

    > Hi Gary,
    >
    > Try r.Parent.Parent.Name
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    >
    > "Gary''s Student" <[email protected]> wrote in message
    > news:[email protected]...
    > > How do I get the Workbook name associated with a range?
    > >
    > > Function whereisit(r As Range) As String
    > > MsgBox (r.Address)
    > > MsgBox (r.Worksheet.Name)
    > > whereisit = r.Address & r.Worksheet.Name
    > > End Function
    > >
    > > I need the workbook name as well as the Address and worksheet name.
    > >
    > > Thanks in advance
    > > --
    > > Gary''s Student

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1