+ Reply to Thread
Results 1 to 5 of 5

Activesheet.paste

Hybrid View

Midwinter Activesheet.paste 04-11-2010, 07:00 PM
shg Re: Activesheet.paste 04-11-2010, 07:03 PM
JBeaucaire Re: Activesheet.paste 04-11-2010, 09:47 PM
Midwinter Re: Activesheet.paste 04-11-2010, 10:06 PM
JBeaucaire Re: Activesheet.paste 04-11-2010, 10:33 PM
  1. #1
    Registered User
    Join Date
    04-11-2010
    Location
    Hamilton, New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    2

    Activesheet.paste

    Hi there,

    I'm new to all this as you will be able to tell

    What I am trying to do is select the values in a column and remove the duplicates. I recorded a macro and then edited it to suit me. The piece that is failing is ActiveSheet.Paste. I have already tried ActiveSheet.PasteSpecial as well as changing it to Select.Range("F1") followed by Selection.Paste and Selection.pastespecial. It still fails with the error 1004.

    Thanks for any help.

     Range("F2").Select
            If Selection.Value <> "" Then
                Columns("F:F").Select
                Range("F2:F2000").AdvancedFilter Action:=xlFilterInPlace, Unique:=True
                Selection.Copy
                Application.CutCopyMode = False
                ActiveSheet.ShowAllData
                Selection.ClearContents
                ActiveSheet.Paste
            End If
    Last edited by Midwinter; 04-11-2010 at 07:35 PM. Reason: code tags

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Activesheet.paste

    Welcome to the forum.

    Please take a few minutes to read the forum rules, and then edit your post to add CODE tags.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Activesheet.paste

    If you want to delete the duplicates, leaving one of each of the unique values and base that on the values in column F, I would do this in an empty column and the AutoFilter.

    Option Explicit
    
    Sub DeleDupesByColumnF()
    Dim LC As Long, LR As Long
    
    'Last row and last column
        LR = Cells.Find("*", Cells(Rows.Count, Columns.Count), SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
        LC = Cells.Find("*", Cells(Rows.Count, Columns.Count), SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Column + 2
    
    'Autofilter key column
        Cells(1, LC) = "key"
        Range(Cells(2, LC), Cells(LR, LC)).FormulaR1C1 = "=ISNUMBER(MATCH(RC6,R1C6:R[-1]C6,0))"
        Columns(LC).AutoFilter
        Columns(LC).AutoFilter Field:=1, Criteria1:="TRUE"
        Range("A2:A" & LR).SpecialCells(xlCellTypeVisible).EntireRow.Delete xlShiftUp
        
    
    'cleanup
        ActiveSheet.AutoFilterMode = False
        Columns(LC).ClearContents
    End Sub
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    04-11-2010
    Location
    Hamilton, New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Activesheet.paste

    Thanks heaps. I'll give it a go

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Activesheet.paste

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1