+ Reply to Thread
Results 1 to 5 of 5

moving 'semi'--duplicates up and alongside

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-09-2008
    Location
    Washington State
    MS-Off Ver
    2007
    Posts
    164

    moving 'semi'--duplicates up and alongside

    Attached is a sample file. Column A is an identifer for a specific property. Column B represents improvements to the property. You will notice that column A can repeat, but column B is unique to the Column A. What I hope to do is if Column A repeats itself, move the improvement into a new column, in the same row as the repeating value in Column A. Sheet 2 is a hand-prepared sheet of the desired result. The result will be Column A filled with unique values and Columns B, C, ...holding what was previously in Column B for repeating values of Column A. Hopefully, the example will be a clearer picture of what I am trying to do.

    I have been working on a Macro (as it works well with the other things I am doing) but I am dealing with some faulty scripting (mine!)

    Thank you in advance and any advice you can offer is appreciated!
    Attached Files Attached Files
    Last edited by abuchan; 04-14-2010 at 05:38 PM. Reason: error on results sheet of attached file

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

    Re: moving 'semi'--duplicates up and alongside

    Try this:
    Option Explicit
    
    Sub x()
        Dim wks         As Worksheet
        Dim r           As Range
        Dim iRow        As Long
        Dim iOfs        As Long
    
        Set wks = Worksheets("Sheet1")
        With wks
            .UsedRange.Sort Key1:=.UsedRange(1), Order1:=xlAscending
            Set r = .Range("A1", .Cells(.Rows.Count, "A").End(xlUp))
            iRow = 2
            
            Do While iRow <= r.Rows.Count + r.Row - 1
                iOfs = 1
                With r(iRow, 1)
                    Do While .Offset(iOfs).Value = .Value
                        .Offset(iOfs, 1).Copy Destination:=.Offset(, iOfs + 1)
                        .Offset(iOfs).Resize(, 2).ClearContents
                        iOfs = iOfs + 1
                    Loop
                End With
                iRow = iRow + iOfs
            Loop
            .UsedRange.Sort Key1:=.UsedRange(1), Order1:=xlAscending
        End With
    End Sub
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    11-09-2008
    Location
    Washington State
    MS-Off Ver
    2007
    Posts
    164

    Re: moving 'semi'--duplicates up and alongside

    Thank you. I gave it a try on the sample file and it seems to just delete the repeats in Column A without moving the data in Column B. I need to combine the data as shown in the sample results on Sheet 2. Thank you for your effort!

  4. #4
    Forum Contributor
    Join Date
    11-09-2008
    Location
    Washington State
    MS-Off Ver
    2007
    Posts
    164

    Re: moving 'semi'--duplicates up and alongside

    My aplogies. I think it works very well. I will play with it and respond shortly.

    Thank you.

  5. #5
    Forum Contributor
    Join Date
    11-09-2008
    Location
    Washington State
    MS-Off Ver
    2007
    Posts
    164

    Re: moving 'semi'--duplicates up and alongside

    Works very well! Thank you for your effort.

+ 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