Solved

Remove Absolute Range

Posted on 2013-12-20
9
228 Views
Last Modified: 2013-12-20
In code it references,
ActiveSheet.Range("$A$1:$A$8569").RemoveDuplicates Columns:=1, Header:= _xlYes

How can I tell this to RemoveDups on whatever is in column A?

Please advise and thanks. -R-


Sub ZSHORTV2Step3ReplaceMM17DupsFromNewZSHORTV2()
'
' ZSHORTV2Step3 Macro
'

'
    Sheets("MM17NoDups").Select
    Columns("A:A").Select
    Selection.ClearContents
    Sheets("ZSHORTV2DataPrevious").Select
    Columns("C:C").Select
    Selection.Copy
    Sheets("MM17NoDups").Select
    Columns("A:A").Select
    ActiveSheet.Paste
    Selection.ColumnWidth = 15
'    Columns("A:A").Select
    Application.CutCopyMode = False
    Application.DisplayAlerts = False
    ActiveSheet.Range("$A$1:$A$8569").RemoveDuplicates Columns:=1, Header:= _
        xlYes
    Application.DisplayAlerts = True
    Sheets("ZSHORTV2DataCurrent").Select
    MsgBox ("MM17NoDups Updated")
    Range("A1").Select
End Sub

Open in new window

0
Comment
Question by:RWayneH
  • 3
  • 3
  • 3
9 Comments
 
LVL 31

Accepted Solution

by:
Rob Henson earned 300 total points
ID: 39731437
Change Line 20 to 2 lines as below:

i = ActiveSheet.UsedRange.Rows.Count
ActiveSheet.Range("$A$1:$A$" & i).RemoveDuplicates Columns:=1, Header:= _
        xlYes

Open in new window

Thanks
Rob H
0
 

Author Comment

by:RWayneH
ID: 39731486
Thanks it worked.  Can I extend the question just a little?  After the process runs it does not have the range of only dups selected on the MM17NoDups...  Is there a way to have it finish by selecting the range after the dups are removed?  instead of having the total cells looked at hightlighted?  -R-
0
 
LVL 31

Expert Comment

by:Rob Henson
ID: 39731509
On the particular sheet, is there data in column B as well?

If not:

Range("A1").Select
CurrentRegion.Select

Should select the data in column A

Thanks
Rob
0
 

Author Comment

by:RWayneH
ID: 39731544
Failed on CurrentRegion.Select?  Any other ideas?  -R-
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 39731549
why not just use:

ActiveSheet.Range("A:A").RemoveDuplicates 1, xlYes
0
 
LVL 31

Expert Comment

by:Rob Henson
ID: 39731559
Sorry got syntax wrong

Selection.CurrentRegion.Select
0
 
LVL 14

Assisted Solution

by:Pierre Cornelius
Pierre Cornelius earned 200 total points
ID: 39731560
to select the range once done.
ActiveSheet.Range("A:A").RemoveDuplicates 1, xlYes
  Range(Range("A2"), Range("A2").End(xlDown)).Select

Open in new window

0
 

Author Closing Comment

by:RWayneH
ID: 39731581
Thanks for the help, both solutions worked. -R-
0
 
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 39731586
glad to help :)
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
My experience with Windows 10 over a one year period and suggestions for smooth operation
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

760 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

20 Experts available now in Live!

Get 1:1 Help Now