Solved

Remove Absolute Range

Posted on 2013-12-20
9
240 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

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 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
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: …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

815 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

13 Experts available now in Live!

Get 1:1 Help Now