+ Reply to Thread
Results 1 to 10 of 10

merge 2 columns

  1. #1
    Registered User
    Join Date
    09-12-2008
    Location
    cincinnati, ohio
    Posts
    13

    merge 2 columns

    Hey guys i was wandering if you could help, i am trying to create a macro that merges two columns in excel.

    i have this vba script

    Please Login or Register  to view this content.
    but it only works on row 2 and none of the others. The spread sheet can contain a variable amount of rows in these two columns so i created what i thought would work a range specifier.
    Please Login or Register  to view this content.
    but when i did that it didn't do anything. can anyone help.

  2. #2
    Forum Contributor
    Join Date
    04-11-2005
    Location
    London
    Posts
    259
    Try
    Please Login or Register  to view this content.
    I've replaced your Cell(x,y) code with Range("G1") etc. so that it is a consistent style.

    Hope this helps.

    Martin
    Martin Short

  3. #3
    Registered User
    Join Date
    09-12-2008
    Location
    cincinnati, ohio
    Posts
    13
    thanks for the reply the script you gave seems to delete the H column before merge the data over to column G not sure why though.

  4. #4
    Forum Contributor
    Join Date
    04-11-2005
    Location
    London
    Posts
    259
    I probably should have put some comments in to explain. Copy the code to your module and the comments will be coloured green so you can see what's code and what's comment.

    Please Login or Register  to view this content.
    Make sense?

  5. #5
    Registered User
    Join Date
    09-12-2008
    Location
    cincinnati, ohio
    Posts
    13
    Hey thanks for the help i guess i don't understand.. as the macro works but seems to erase all the data that was in column H except for H1. The thing is they both have data the i need but G2 may be empty but H2 would not be and vise versa

  6. #6
    Forum Contributor
    Join Date
    04-11-2005
    Location
    London
    Posts
    259
    I don't understand. The routine deletes column H, it doesn't delete column H except for Cell H1!

    Regarding the other question, your original question seemed to say that you wanted the concatenated column but wanted to delete the original G and H columns. Is this not the case?

  7. #7
    Forum Contributor
    Join Date
    04-11-2005
    Location
    London
    Posts
    259
    Actually having re-read the last sentence, I can see a little more of what you are wanting. Do you have a 'master' column which will always have data in?

  8. #8
    Registered User
    Join Date
    09-12-2008
    Location
    cincinnati, ohio
    Posts
    13
    Not between the data that those two hold. They share the same type of data just one shows outgoing and another incoming so i was trying to merge them so that i had one column incoming and outgoing together. and yes then i want to delete the leftover column.

  9. #9
    Forum Contributor
    Join Date
    04-11-2005
    Location
    London
    Posts
    259
    In which case the code I wrote does just that.

  10. #10
    Registered User
    Join Date
    09-12-2008
    Location
    cincinnati, ohio
    Posts
    13
    ok 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. Merge date and time columns without loosing time
    By robhargreaves in forum Excel General
    Replies: 7
    Last Post: 07-11-2014, 09:25 PM
  2. Merge Columns B,C,D,E and F, If duplicates exist in Column A
    By julia81 in forum Excel Programming / VBA / Macros
    Replies: 84
    Last Post: 03-25-2014, 03:37 PM
  3. converting rows and columns to merge data
    By SSOIWP in forum Excel General
    Replies: 8
    Last Post: 09-09-2008, 09:08 AM
  4. Excel 2007 : Merge two Columns with a space
    By stitchup in forum Excel General
    Replies: 2
    Last Post: 07-24-2008, 02:38 AM
  5. Replies: 1
    Last Post: 11-12-2006, 06:08 AM

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