Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8339007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:45:58+00:00 2026-06-09T04:45:58+00:00

I have a column of cells whose values are something like this: a a

  • 0

I have a column of cells whose values are something like this:

a
a
b
b
c
c
c
c
d
e
f
f

etc.

I’m looking to take the non-duplicated values and paste them into a new column. My pseudocode for this is as follows:

ActiveSheet.Range("a1").End(xlDown).Select
aend = Selection.Row
for acol= 1 to aend
    ActiveSheet.Range("b1").End(xlDown).Select
    bend = Selection.Row
        'if Cells(1,acol).Value <> any of the values in the range Cells(2,1).Value
        'to Cells(2,bend).Value, then add the value of Cells(1,acol) to the end of 
        'column b.

Does my logic in this make sense? I’m not sure how to code the commented portion. If this isn’t the most efficient way to do it, could someone suggest a better way? Thanks so much!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T04:45:59+00:00Added an answer on June 9, 2026 at 4:45 am

    Depending on which version of Excel you are using, you can use some built-in Excel functionality to obtain what you want- the whole solution depends on your level of skill with VBA.

    Excel 2003:

    You can use the Advancedfilter method (documentation) of your range to obtain the unique values and copy them to your target area. Example:

    With ActiveSheet
        .Range("A1", .Range("A1").End(xlDown)).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=.Range("B1"), Unique:=True
    End With
    

    Where B1 is the first cell of the column you wish to copy the unique values to. The only problem with this method is that the first row of the source column (“A1”) will be copied to the target range even if it is duplicated. This is because the AdvancedFilter method assumes that the first row is a header.

    Therefore, adding an additional code line we have:

    With ActiveSheet    
        .Range("A1", .Range("A1").End(xlDown)).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=.Range("B1"), Unique:=True
        .Range("B1").Delete Shift:=xlShiftUp
    End With
    

    Excel 2007 / 2010:

    You can use the same method as above, or use the RemoveDuplicates method (documentation). This is similar to the AdvancedFilter method, except that RemoveDuplicates works in-place, which means you need to make a duplicate of your source column and then perform the filtering, for example:

    With ActiveSheet
        .Range("A1", .Range("A1").End(xlDown)).Copy Destination:=.Range("B1")
        .Range("B1", .Range("B1").End(xlDown)).RemoveDuplicates Columns:=1, Header:=xlNo
    End With
    

    The final parameter Header controls whether the first cell of the source data is copied to the destination (if it’s set to true then the method similarly to the AdvancedFilter method).

    If you’re after a “purer” method, then you can use a VBA Collection or dictionary – I am sure that someone else will offer a solution with this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an HTML table whose cells contain, among other things, spans, like this:
I have a table whose header looks like this (I've simplified it): id, a1,
I have a form with the fields inside table cells. On the last column
hi i have a datagridview whose first column (index = 0) is a checkbox
I have got an Excel file in this form : Column 1 Column 2
Question should be self explanatory. I have a datagridview which has a column whose
On this page Ive been working on forever , I have this column headed
I have a unbound DataGridView with two columns. First column is just string values.
I have a cell array which contains 7 matrices of varying column and length
I have three buttons in a three column structure in a custom cell in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.