+ Reply to Thread
Results 1 to 3 of 3

What Worksheet (Parent) was my Range selected from?

Hybrid View

  1. #1
    Registered User
    Join Date
    08-08-2012
    Location
    Detroit, MI
    MS-Off Ver
    Excel 2010
    Posts
    15

    What Worksheet (Parent) was my Range selected from?

    Hi All,
    [first post!]
    I'm new at this, so please feel free to point out better methods. However, I'd still also like to know the answer to the original question.
    I have 2 sheets I'm concerned with. I have no idea what the user will have named them, nor what sheet they started on when they started the macro. So I have them navigate to a Destination sheet, then a source Data sheet, one at a time. They select any cell (or range) on both of these worksheets. This forces them to view the data and make sure they know where their information is being migrated from and to. It's also just the first way I figured out how to get them to pick a range!

    Basically, I need to know the names of the Destination and source Data worksheets so that I can refer to and select them! See *** below. Thanks so much.


    Sub UpdateQTY()
    
        Dim DataRange, DestRange As Range
    
        Set DestRange = GetDest()
        Set DataRange = GetData()
        
    '***[RIGHT HERE I WANT TO SELECT THE WORKSHEET THAT DestRange IS FROM, SO THAT I CAN THEN GATHER THE COLUMN NUMBER INFO I NEED.]
      
        PartNumbCol = ColNum("PART NUMBER")
        QtyCol = ColNum("QTY")
        DateCol = ColNum("Date")
        
     '...
    
    End Sub
    
    
    Function GetDest() As Range
    Dim DestRange As Range
        
        Set DestRange = Application.InputBox("1. Navigate to the destination sheet that you want to update." & Chr(13) _
        & "2. Select any cell to confirm the sheet." & Chr(13) & "3. Click 'OK'.", Type:=8)
        
        Set GetDest = DestRange
    End Function
    
    
    Function GetData() As Range
    Dim DataRange As Range
        
        Set DataRange = Application.InputBox("1. Navigate to the sheet containing new source data." & Chr(13) _
        & "2. Select any cell to confirm the sheet." & Chr(13) & "3. Click 'OK'.", Type:=8)
        
        Set GetData = DataRange
    End Function

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: What Worksheet (Parent) was my Range selected from?

    Hello ShawnW
    ,

    Welcome to the Forum!

    Add this line...
        DestRange.Parent.Activate
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: What Worksheet (Parent) was my Range selected from?

    Hello ShawnW
    ,

    Welcome to the Forum!

    Add this line...
        DestRange.Parent.Activate

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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