Consulting

Results 1 to 5 of 5

Thread: [VBA]:How to use VBA to merge 2 sheets into one with the same ID

  1. #1

    Question [VBA]:How to use VBA to merge 2 sheets into one with the same ID

    How to use VBA to merge 2 sheets into one with the same ID

    1.png
    2.png
    3.png <- there is the expected result.

    Thanks!

  2. #2
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location
    give this a spin
    Attached Files Attached Files

  3. #3
    They are not SQL.
    The data stored in Excel only.
    It should not involved in SQL.
    Can : stSQLstring = "Select [Sheet1$].[ID], [Sheet1$].[Name], " & _ "[Sheet2$].[Purchase] From " & _
    "([Sheet1$] Left Join [Sheet2$] On " & _
    "[Sheet1$].[ID] = [Sheet2$].[ID]);"
    do the mapping?

    Anyway, thank you for your help!

  4. #4
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location
    Have you try running it? Yes, I used SQL to extract, that is the beauty of programming, if you know how to do it, you can do anything.

    Put your info onto Sheet1 and Sheet2 just like what you have in your question and run the code. (never mind - I already did this for you - so just run the code)

  5. #5
    Tried. Thanks anyway. Going to understand it and reproduct it!

Tags for this Thread

Posting Permissions

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