Solved

Remove Absolute Range

Posted on 2013-12-20
9
248 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
9 Comments
 
LVL 33

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 33

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
Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 

Author Comment

by:RWayneH
ID: 39731544
Failed on CurrentRegion.Select?  Any other ideas?  -R-
0
 
LVL 14

Expert Comment

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

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

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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

687 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