+ Reply to Thread
Results 1 to 9 of 9

VBA array difference

  1. #1
    Registered User
    Join Date
    08-25-2012
    Location
    esonnXandd
    MS-Off Ver
    Excel 2003
    Posts
    3

    VBA array difference

    I have a VBA code to compare two columns (A & B) having comma separated values. Two custom functions are defined in VB code and I get the result in next two columns (C & D). Col C gives me values that exist in A but not in B. Col. D gives me values that exist in B but not in A.

    I want a custom function which should give me values common in both A and B columns.

    Suppose
    I want
    Col A Col B Col C Col D Col E
    a,b,c,d b,c,d,f a f b,c,d

    Details attached in excel file
    csv-split-function.xlsm

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,637

    Re: VBA array difference

    Try

    =GetAllDiff($A1,$B1,COLUMN(A1))
    Then copy to the right

    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: VBA array difference

    Hi jindon
    very good code, but you missed to use a(3), I suggest some changes
    Please Login or Register  to view this content.
    Last edited by patel45; 09-03-2012 at 04:38 PM.
    If solved remember to mark Thread as solved

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,637

    Re: VBA array difference

    patel45

    1st column = appears only in A1
    2nd column = appears only in B1
    3rth column = appears in both

    That's how I read the problem.

  5. #5
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: VBA array difference

    Yes, you are right, I copied only 1 time to the right, I read bad I apologize
    Last edited by patel45; 09-04-2012 at 01:54 AM.

  6. #6
    Registered User
    Join Date
    08-25-2012
    Location
    esonnXandd
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: VBA array difference

    Dear Jindon,
    That was a Great Help for me.

    Nikhilesh

  7. #7
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: VBA array difference

    @ nikhileshp

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  8. #8
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: VBA array difference

    Why so complicated ?
    Please Login or Register  to view this content.



  9. #9
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: VBA array difference

    very good snb, but to complete the job
    Please Login or Register  to view this content.
    b

+ 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