×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Removing multiple lines based on first field

Removing multiple lines based on first field

Removing multiple lines based on first field

(OP)
Hi

Can anyone help with a simple macro that will take 3 or 4 columns Excel files … and remove all the rows that has multiple first field. Example :

123, 34234, 2232,2233,
123, 43294, 3233, 32
124, 5442, 4445, 4332
124, 44432, 54322, 4333
124, 4345, 4344, 4332
125, 4343,43215, 4334,
125, 435, 3443, 4345

And return a file with only :
123, 34234, 2232,2233,
124, 5442, 4445, 4332
125, 4343,43215, 4334,

Etc….. I have files with 20000+ lines….

Much appreciated…

RE: Removing multiple lines based on first field

claver,

rather than write a macro (VBA code), how about using the Auto Filter capabilities within Excel.  Include a label for each column (top row) and then select the Data, Filter, Auto Filter.  You can then filter out repeated rows . . .  perhaps writing a macro will be faster, but something for you to think about and attempt.

be sure all the data is continuous (no open rows between data) and the same for columns.  If there are non-continuous rows/columns, then highlight all the data before executing the filter commands.

Good Luck!
-pmover

RE: Removing multiple lines based on first field

(OP)
Thanks pmover ... I will give that a go

RE: Removing multiple lines based on first field

Also, you may need a "helper" column with a formula like =COUNTIF(A:A,A1) in every row, which will show you the number of occurences of each entry in column A. Then you can filter on the formula result being equal to 1 to remove duplicates. Or sort and throw away rows where it is larger than 1.

Cheers,
Joerd

Please see FAQ731-376: Eng-Tips.com Forum Policies for tips on how to make the best use of Eng-Tips.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources