+ Reply to Thread
Results 1 to 6 of 6

Get data from another sheet

Hybrid View

efernandes67 Get data from another sheet 09-18-2010, 05:11 PM
TMS Re: Get data from another... 09-18-2010, 05:32 PM
efernandes67 Re: Get data from another... 09-18-2010, 06:04 PM
shg Re: Get data from another... 09-18-2010, 06:50 PM
TMS Re: Get data from another... 09-18-2010, 07:01 PM
efernandes67 Re: Get data from another... 09-19-2010, 05:32 AM
  1. #1
    Registered User
    Join Date
    01-01-2005
    MS-Off Ver
    2007
    Posts
    368

    Get data from another sheet

    Hi,

    I am in sheet("game1") and I want to get some info sheet("game2") unsing the match function.

    I have the following code that works just fine. but!!!
    
    Sub Test1()
        Dim rw as long 
    
        Application.ScreenUpdating = False
        Sheets("game2").Select
       
        With Application.WorksheetFunction
            rw = .Match(, Range("G:G"), 0)
        End With
    
        Sheets("game1").Select
        Application.ScreenUpdating = True
    end sub
    I want to make a change so that I dont have to swap between sheets.
    I tried the following code, but I am missing something!
    Sub Test2()
        Dim rw as long 
        Dim wsData As Worksheet
    
        'Set wsData = Worksheets("game2")
    
        With Application.WorksheetFunction
            rw = .Match(, Range("G:G"), 0)
        End With
    end sub
    Regards,
    Elio Fernandes
    Last edited by efernandes67; 09-19-2010 at 05:33 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,494

    Re: Get data from another sheet

    I'm struggling toget your code to compile, let alone run.

    Please post the workbook with the working code.

    Regards

  3. #3
    Registered User
    Join Date
    01-01-2005
    MS-Off Ver
    2007
    Posts
    368

    Re: Get data from another sheet

    Here is the file that you asked for.
    I want to use procedure "Test2" after you correcting the error in it.

    Regards,
    Elio Fernandes
    Attached Files Attached Files
    Last edited by shg; 09-18-2010 at 06:49 PM. Reason: deleted spurious quote

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Get data from another sheet

    efernandes67, please don't quote whole posts; it's just clutter.

    Use the REPLY button, not the QUOTE button.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,494

    Re: Get data from another sheet

    OK:

    Sub GetRow_G2()
    
        With Sheets("game2")
            Range("G7").Value = "NF"
            On Error Resume Next
            Range("G7").Value = _
                Application.WorksheetFunction.Match _
                    (Sheets("game1").Range("E7"), .Range("G:G"), 0)
            On Error GoTo 0
        End With
    
    End Sub


    You could combine this with a Worksheet Change event (in sheet game1) so that the field will update automatically:

    Private Sub Worksheet_Change(ByVal Target As Range)
    
    If Intersect(Target, Range("E7")) Is Nothing Then Exit Sub
    Application.EnableEvents = False
    GetRow_G2
    Application.EnableEvents = True
    
    End Sub

    And if you added Data Validation on the name input field (using the list of names on sheet game2) you could ensure that you don't mis-enter any names.

    Regards

  6. #6
    Registered User
    Join Date
    01-01-2005
    MS-Off Ver
    2007
    Posts
    368

    Re: Get data from another sheet

    Thanks, it's just fine.

    Regards
    Elio Fernandes

+ 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