?
Solved

Remove Absolute Range

Posted on 2013-12-20
9
Medium Priority
?
255 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 1200 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

765 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