+ Reply to Thread
Results 1 to 5 of 5

VBA Unique values from 2 columns based on condition

  1. #1
    Registered User
    Join Date
    03-01-2020
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    28

    VBA Unique values from 2 columns based on condition

    Hello All,

    I have 2 columns - A and B and I want to extract unique values from column A and B . When Column B is not null then it should be considered otherwise column A.

    Below is the code I use to copy from 1 column,

    Data.Range("F2:F" & lastrow).SpecialCells(xlCellTypeVisible).Copy
    Anchor.Cells(10, 1).PasteSpecial
    Anchor.Columns(1).RemoveDuplicates Columns:=Array(1)

    how do I modify this to my requirement. Please provide your suggestions. Have attached an excel as an example.

    Thanks

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA Unique values from 2 columns based on condition

    Here's one way

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,295

    Re: VBA Unique values from 2 columns based on condition

    Give the attached a try, hopefully I have understood the requirement.

  4. #4
    Registered User
    Join Date
    03-01-2020
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    28

    Re: VBA Unique values from 2 columns based on condition

    Thank you, this solution worked for me.

  5. #5
    Registered User
    Join Date
    03-01-2020
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    28

    Re: VBA Unique values from 2 columns based on condition

    Thank you for the solution but could the same be replicated without calling scripts (Scripting Dictionary) ??

    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] Generate unique list of values based on condition in another table column with VBA
    By dabasir in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-16-2019, 09:12 PM
  2. count unique values based on 1 condition
    By penfolda in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-05-2014, 10:28 PM
  3. Required Unique values based on if condition (array)
    By Punnam in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-30-2014, 01:09 AM
  4. Counting unique values based on condition in a different column
    By rafuk73 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-21-2014, 02:59 PM
  5. [SOLVED] counting unique values based on a condition with autofiltering
    By sammybr in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-20-2014, 06:27 PM
  6. Count unique values based on condition
    By pradeev in forum Excel General
    Replies: 4
    Last Post: 06-12-2012, 10:43 AM
  7. Replies: 2
    Last Post: 01-17-2012, 07:48 AM

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