Results 1 to 16 of 16

No experience, special copy and paste column macro

Threaded View

shuynh84 No experience, special copy... 10-30-2014, 02:29 PM
pjwhitfield Re: No experience, special... 10-30-2014, 02:35 PM
shuynh84 Re: No experience, special... 10-30-2014, 02:48 PM
Leith Ross Re: No experience, special... 10-30-2014, 02:39 PM
shuynh84 Re: No experience, special... 10-30-2014, 02:40 PM
pjwhitfield Re: No experience, special... 10-30-2014, 04:51 PM
shuynh84 Re: No experience, special... 10-30-2014, 05:02 PM
Leith Ross Re: No experience, special... 10-30-2014, 06:20 PM
shuynh84 Re: No experience, special... 10-31-2014, 09:19 AM
Leith Ross Re: No experience, special... 10-31-2014, 11:40 AM
shuynh84 Re: No experience, special... 10-31-2014, 11:59 AM
Leith Ross Re: No experience, special... 10-31-2014, 12:02 PM
shuynh84 Re: No experience, special... 10-31-2014, 12:09 PM
Leith Ross Re: No experience, special... 10-31-2014, 12:16 PM
shuynh84 Re: No experience, special... 10-31-2014, 12:29 PM
Leith Ross Re: No experience, special... 10-31-2014, 01:10 PM
  1. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: No experience, special copy and paste column macro

    Hello shuynh84,

    This should be close to what you want. A new sheet "Result" has been added along with a button to run the macro.

    The sorted results are in column "A" while columns "B" and "C" display the unique entries and their counts.

    Sub Macro1()
    
        Dim DataIn  As Variant
        Dim DataOut As Variant
        Dim Dict    As Object
        Dim Item    As Variant
        Dim Key     As Variant
        Dim n       As Long
        Dim Rng     As Range
        Dim Wks     As Worksheet
        
            Set Wks = Worksheets("Summary")
            
            Set Rng = Wks.Range("A1").CurrentRegion
            Set Rng = Intersect(Rng, Rng.Offset(1, 1))
            
                DataIn = Rng.Value
                
                ReDim DataOut(Rng.Cells.Count - 1, 0)
                
                    Set Rng = Worksheets("Result").Range("A2")
                
                    For Each Item In DataIn
                        DataOut(n, 0) = Item
                        n = n + 1
                    Next Item
        
                    Set Rng = Rng.Resize(n, 1)
                    Rng.Value = DataOut
                
                    Set Wks = Rng.Parent
                
                    Wks.Sort.SortFields.Clear
                    Wks.Sort.SortFields.Add Key:=Rng, SortOn:=xlSortOnValues, Order:=xlAscending
                
                    With Wks.Sort
                        .Header = xlNo
                        .MatchCase = False
                        .Orientation = xlTopToBottom
                        .SetRange Rng
                        .Apply
                    End With
                
                    DataOut = Rng.Value
                    
                Set Dict = CreateObject("Scripting.Dictionary")
                Dict.CompareMode = vbTextComapre
                
                For Each Item In DataOut
                    Key = Trim(Item)
                    If Key <> "" Then
                        If Not Dict.Exists(Key) Then
                            Dict.Add Key, 1
                        Else
                            Item = Dict(Key)
                            Dict(Key) = Item + 1
                        End If
                    End If
                Next Item
                
                n = 0
                
                For Each Key In Dict.Keys
                    Rng.Offset(n, 1).Resize(1, 2).Value = Array(Key, Dict(Key))
                    n = n + 1
                Next Key
                
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] No Experience – Need a specific copy and paste macro
    By shuynh84 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-31-2014, 03:15 PM
  2. [SOLVED] Simple copy and paste macro- Paste special help needed.
    By hernancrespo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-20-2012, 07:02 AM
  3. Replies: 0
    Last Post: 09-18-2012, 11:47 AM
  4. [SOLVED] Macro to find SKU in column; then copy data in row and paste special (values)
    By Starkey in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-13-2012, 06:05 AM
  5. Macro to copy and paste special values for column data and filter column data
    By ascottbag in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-10-2012, 02:15 PM

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