Solved

Select then remove duplicates

Posted on 2014-11-27
2
74 Views
Last Modified: 2014-11-27
can an Expert assist me with this, I am sure it is simple but obviously not for me.

I am using the below code to select the current range:

Range(Range("A98"), Cells.SpecialCells(xlCellTypeLastCell)).Select

I then want to remove all duplicates from column B within that range [without using a named range like

ActiveSheet.Range("$A$98:$AB$103").RemoveDuplicates Columns:=2, Header:= _
        xlNo

and then I want to sort on column B

Row 98 is the header row for the Range and the number of rows below 98 will vary every time we run the report.

Thanks
0
Comment
Question by:Jagwarman
2 Comments
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
Comment Utility
Hi,

pls try

Set myRange = Range(Range("A98"), Cells.SpecialCells(xlCellTypeLastCell))
myRange.RemoveDuplicates Columns:=2, Header:=xlYes
myRange.Sort key1:=Range("B98"), _
      order1:=xlAscending, Header:=xlYes

Open in new window

Regards
0
 

Author Comment

by:Jagwarman
Comment Utility
I changed this myRange.RemoveDuplicates Columns:=2, Header:=xlYes

to this

myRange.RemoveDuplicates Columns:=2, Header:=xlNo

And it works

Thanks Rgonzo
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now