+ Reply to Thread
Results 1 to 3 of 3

VBA macros for multiple matches in different sheets

  1. #1
    Registered User
    Join Date
    12-05-2012
    Location
    chennai
    MS-Off Ver
    Excel 2007
    Posts
    2

    Post VBA macros for multiple matches in different sheets

    HI

    I need a macros for multiple matches in different sheet and need to return the all values for unique id
    I put an example case for you
    Sheet 1 contains unique ids and values .Values will repeat

    In other sheet also values will repeats and will value corresponding values for the each repating values

    I need output like for one unique id all values corresponding values as i provided in the example .

    Please help

    Thanks alot

    Sheet1 contains

    id1 isin1
    id2 isin1
    id3 isin2
    id4 isin3

    Sheet2 contains


    isin1 value1 age1
    isin1 value2 age2
    isin2 value3 age3
    isin3 value4 age4
    isin3 value5 age5
    isin1 value6 age6
    isin3 value7 age7


    Output


    id1 isin1 value1 age1
    id1 isin1 value2 age2
    id1 isin1 value6 age6

    id2 isin1 value1 age1
    id2 isin1 value2 age2
    id2 isin1 value6 age6

    id3 isin2 value3 age3

    id4 isin3 value4 age4
    id4 isin3 value5 age5
    id4 isin3 value7 age7

  2. #2
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: VBA macros for multiple matches in different sheets

    Hi I will get back to u with some solution !

  3. #3
    Registered User
    Join Date
    12-05-2012
    Location
    chennai
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: VBA macros for multiple matches in different sheets

    I tried programming . But i couldnt print the value in the cell in the range .

    Could you help me in it




    Option Explicit

    Sub test()

    Dim varSheetA As Variant
    Dim varSheetB As Variant
    Dim varSheetC As Variant
    Dim strRangeToCheck1 As String
    Dim strRangeToCheck2 As String
    Dim strRangeToCheck3 As String




    Dim iRow1 As Long
    Dim iCol1 As Long
    Dim iRow2 As Long
    Dim iCol2 As Long
    Dim iRow3 As Long
    Dim iCol3 As Long



    strRangeToCheck1 = "A1:B5"
    strRangeToCheck2 = "D1:E6"
    strRangeToCheck3 = "f1:h22"



    Debug.Print Now

    varSheetA = Worksheets("Sheet1").Range(strRangeToCheck1)
    varSheetB = Worksheets("Sheet1").Range(strRangeToCheck2)
    varSheetC = Worksheets("Sheet1").Range(strRangeToCheck3)

    ' or whatever your other sheet is.
    Debug.Print Now

    For iRow1 = LBound(varSheetA, 1) To UBound(varSheetA, 1)
    For iCol1 = LBound(varSheetA, 2) To UBound(varSheetA, 2)


    For iRow2 = LBound(varSheetA, 1) To UBound(varSheetA, 1)
    For iCol2 = LBound(varSheetA, 2) To UBound(varSheetA, 2)



    If varSheetA(iRow1, 2) = varSheetB(iRow2, 1) Then


    varSheetC(iRow1, 1).Value = varSheetA(iRow1, 1).Value


    Else
    End If


    Next iCol2
    Next iRow2

    Next iCol1
    Next iRow1

    End Sub

+ 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