Solved

Remove Absolute Range

Posted on 2013-12-20
9
237 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 32

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 32

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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 14

Expert Comment

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

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

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

911 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

21 Experts available now in Live!

Get 1:1 Help Now