+ Reply to Thread
Results 1 to 23 of 23

Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

  1. #1
    Registered User
    Join Date
    02-06-2015
    Location
    Italy
    MS-Off Ver
    Office 2007 & 2013
    Posts
    78

    Question Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

    Hello,



    Please I need your help to to concatenate data -with id number- in 2 separate table of 2 separate sheets.
    I've attached below a file INFO to explain you.
    I've also attached a "real" file (the number of columns may change) BUT cutted because the rows in the original file are more than 37000 (for better identify the two columns I've marked yellow in both sheets)


    Thank you very much for help!
    Attached Files Attached Files
    Last edited by 823; 02-08-2015 at 07:44 AM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

    Check it out,
    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor
    Join Date
    05-11-2013
    Location
    Wales
    MS-Off Ver
    Excel 2010
    Posts
    586

    Re: Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

    Hi 823,

    I am not sure if what I have attached is what you are after but I have done it using formulas instead of a macro.

    Regards

    peterrc
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    02-06-2015
    Location
    Italy
    MS-Off Ver
    Office 2007 & 2013
    Posts
    78

    Re: Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

    Quote Originally Posted by davesexcel View Post
    Check it out,

    It seems that It works, thanks
    But in the code If I change DB with another cell ex GY It doesn't works anymore.....WHY?

    Sub UseFormula()
    Dim ws As Worksheet
    Dim Rws As Long, Frng As Range
    Set ws = Worksheets("1")
    With ws
    Rws = .Cells(Rows.Count, "A").End(xlUp).Row
    Set Frng = .Range(.Cells(2, "GY"), .Cells(Rws, "GY"))
    Frng = "=IFERROR(VLOOKUP(RC[-105],'2'!C[-105]:C[-104],2,0),""Not Found"")"
    Frng.Value = Frng.Value
    End With

    End Sub
    thanks

  5. #5
    Registered User
    Join Date
    02-06-2015
    Location
    Italy
    MS-Off Ver
    Office 2007 & 2013
    Posts
    78

    Re: Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

    Quote Originally Posted by peterrc View Post
    Hi 823,
    Thanks you very much!!


    It works very well with your forumla!!!
    Last edited by 823; 02-08-2015 at 10:15 AM.

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

    Why would you change it to "GY" your sample showed "DB" ?

    You have to change the formula as well,
    Comment this part of the code
    Frng.Value = Frng.Value
    -then run the code to see what the formulas looks like.


    Please Login or Register  to view this content.

  7. #7
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

    Don't quote whole posts -- it's just clutter. If you are responding to a post out of sequence, limit quoted content to a few relevant lines that makes clear to whom and what you are responding.

  8. #8
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

    Guess it was supposed to be GY
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    02-06-2015
    Location
    Italy
    MS-Off Ver
    Office 2007 & 2013
    Posts
    78

    Re: Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

    thanks davesexcel

    I saw that If I need to change columns (DB to GY) the only thing to change is the column's name (GY) and some numbers...

    where I can find/count the numbers 128-127 OR 206-205 ?

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.


    Please I need to understand where I can count that numbers..... If I need to apply the macro to others file...


    thanks!
    Last edited by 823; 02-08-2015 at 10:50 AM.

  10. #10
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

    Perhaps this will help
    Pic1.jpg

    To see what the formula looks like in VBA, this is the easiest way.

    Run the macro recorder, select the cell with the formula, and select inside the formula bar.
    Hit enter key.
    Stop the macro recorder.
    See what the formula looks like in VBA

    recordmacro.jpgFormulaVBA.jpgVBAFormula.jpg

  11. #11
    Registered User
    Join Date
    02-06-2015
    Location
    Italy
    MS-Off Ver
    Office 2007 & 2013
    Posts
    78

    Re: Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

    Thanks!


    but where I can read in excel that column GY is NUMBER 207 OR 206 ????

  12. #12
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,724

    Re: Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

    In a blank cell somewhere, you can enter this formula:

    =COLUMN(GY1)

    Hope this helps.

    Pete

  13. #13
    Registered User
    Join Date
    02-06-2015
    Location
    Italy
    MS-Off Ver
    Office 2007 & 2013
    Posts
    78

    Re: Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

    Are you sure?

    With

    =COLUMN(GY1)

    It appears: #NAME?

    It doesn't give me the column's number!

  14. #14
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,724

    Re: Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

    Perhaps you have mis-spelt the word COLUMN.

    Pete

  15. #15
    Registered User
    Join Date
    02-06-2015
    Location
    Italy
    MS-Off Ver
    Office 2007 & 2013
    Posts
    78

    Re: Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

    no....I tryed another time, on my excel (2013) It retourns #NAME?

    any other way to know column number please?

  16. #16
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

    Please Login or Register  to view this content.

  17. #17
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

    when you type
    =colu

    does in not autocomplete as =column

  18. #18
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,724

    Re: Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

    As you are in Italy, perhaps you need the Italian version of the word COLUMN (sorry, I don't know what it is).

    Pete

  19. #19
    Registered User
    Join Date
    02-06-2015
    Location
    Italy
    MS-Off Ver
    Office 2007 & 2013
    Posts
    78

    Re: Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

    Italian i think It is "COLONNE" OR "COLONNA" but It retourns me always number "1"

  20. #20
    Registered User
    Join Date
    02-06-2015
    Location
    Italy
    MS-Off Ver
    Office 2007 & 2013
    Posts
    78

    Re: Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

    Quote Originally Posted by davesexcel View Post
    Please Login or Register  to view this content.

    this works, thanks!

  21. #21
    Registered User
    Join Date
    02-06-2015
    Location
    Italy
    MS-Off Ver
    Office 2007 & 2013
    Posts
    78

    Re: Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

    Sorry DAVESEXCEL,

    so to insert the results in AP column I have to use this code I've modified myself....

    Please Login or Register  to view this content.

    Can you check It please if It is correct for AP column?

    THANKS
    Last edited by 823; 02-08-2015 at 12:46 PM.

  22. #22
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

    Did you try it?


    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Why not use my previous post that explains how see what your formula looks like in VBA

    But you can simplify it by using
    Please Login or Register  to view this content.

  23. #23
    Registered User
    Join Date
    02-06-2015
    Location
    Italy
    MS-Off Ver
    Office 2007 & 2013
    Posts
    78

    Re: Macro needed to Concatenate data in 2 separate tables of 2 separate sheets

    WAW!

    so with this macro:

    Please Login or Register  to view this content.
    To change the "column result", I've just to change the column's name (for ex. DB); It is right?


    Great! It is very simple!


    VERY THANKS!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro Needed to Concatenate Data in separate COLUMNS
    By 823 in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 03-11-2015, 04:34 PM
  2. [SOLVED] Macro Needed to Concatenate Data in separate ROWS
    By 823 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 02-21-2015, 11:35 AM
  3. [SOLVED] Macro needed to Concatenate Data in separate TABLES
    By 823 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 02-08-2015, 07:42 AM
  4. Replies: 4
    Last Post: 11-22-2010, 12:57 PM
  5. Replies: 3
    Last Post: 08-12-2010, 03:45 PM

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