Loop for Transpose

DetroitDavid

Board Regular
Joined
Jul 20, 2013
Messages
211
I’m wondering if someone could help me write a loop.

I am a foreclosure defense specialist. I help people who’s home is in the foreclosure process. Very rewarding, but also very tedious. I need to call thousands of people who show up on public record after the bank sends an address to foreclosure. I have an auto dialer but I am struggling with getting the information into excel in the right format to use the dialer.

I have a spreadsheet, 3,000 +/- rows and 49 columns. The last 36 of the columns are 12 sets each of FirstName, LastName, Phone (see screenshot below - if it worked – Note all information is bogus).

Each row is a unique postal address, but each address I import can have up to 12 contact numbers. Some have none, some 1, and so forth.

I need to do something like using the Paste Special Transform feature.

For each row, I want to have the information in the first 7 columns repeated down so it now is duplicated into X rows; then for each FirstName, LastName, Phone “set” put one set onto each of the X rows with duplicate info on the first 7 cols. So I end up with (in this case) X records that have the same address, but potentially X different names and phone numbers. I only need the new split record written back if it has a unique phone number for that address.

So, within a loop, for each row (unique address) I’d like it to count the phone numbers from the 12 sets of 3. Then if a phone number exists, insert that many rows, duplicate the information from the first few cells x times, then put the FirstName, LastName and corresponding Phone number on each of the x records.

The average number of phone numbers listed for an address is about 4, so theoretically, if I start with a 3,000 record spreadsheet, it might end up being 12,000 rows when completed.

I don’t know where to start, and would really appreciate someone seeing this as a simple challenge and helping me out.

Thank you so much in advance…

David




Excel 2010
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAX
1ActionAddressCityStateZipImportAuctionCallTimeNotesFirst_ContactLast_ContactPhone_ContactFirst_Name_1Last_Name_1Phone_1First_Name_2Last_Name_2Phone_2First_Name_3Last_Name_3Phone_3First_Name_4Last_Name_4Phone_4First_Name_5Last_Name_5Phone_5First_Name_6Last_Name_6Phone_67Last_Name_7Phone_7First_Name_8Last_Name_8Phone_8First_Name_9Last_Name_9Phone_9First_Name_10Last_Name_10Phone_10First_Name_11Last_Name_11Phone_11First_Name_12Last_Name_12Phone_12
2121810 Eastland CtHighland ParkMI480891745Feb 4Feb 12(586) 731-1234CynthiaBury(586) 558-1234CindyBury(586) 558-1234CindyBury(586) 677-1234CindyBury(586) 855-4364(586) 558-1234
3225394 Waldorf StDetroitMI480475730Feb 4Feb 12DebMiley(586) 726-1234HowardMileyDeborahMileyHowardMiley(586) 294-1234HowardMiley(586) 945-6072MileyHoward
436385 68th St SEWarrenMI480443814Feb 4Feb 12WandaLatondras(586) 709-1234WandaLatondras(586) 677-1234WandaLatondras(586) 677-1234(586) 709-1234(586) 677-1234
546526 Tanglewood Dr SEChesterfieldMI485052710Feb 4Feb 12AndrewURBANAnnURBAN(586) 294-1234(586) 294-1234(586) 294-1234
65830 Adams St SEBruce TwpMI484639727Feb 4Feb 12RoyKIRCHOFF(586) 945-1234RoyKirchoffRoyKirchoff(586) 477-1234RoyKirchoff(586) 945-1234RoyKirchoff(586) 558-8659RoyKirchoff
764087 Silver Lake RdSterling HeightsMI484339724Feb 4Feb 12KathleenStitchick(586) 731-1234(586) 477-1234
872017 Morgan RdHarrison TownshipMI484581437Feb 4Feb 12RobertDecker(586) 383-1234RobertDeckerRobertDecker(586) 777-1234(586) 726-1234(586) 777-1234
Mar Calls
 
Last edited:

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Code:
Sub makeList()

    Dim raw As Worksheet
    Dim list As Worksheet
    
    Dim nextRow As Integer
    
    nextRow = 2
    
    Set raw = Sheets("Mar Calls")
    Set list = Sheets("List") 'Change me to your destination sheet name
    
    With raw
        For x = 2 To .Cells(Rows.Count, 2).End(xlUp).Row
            For y = 16 To 49 Step 3
                list.Range(list.Cells(nextRow, 1), list.Cells(nextRow, 10)).Value = _
                    .Range(.Cells(x, 1), .Cells(x, 10)).Value
                    
                If .Cells(x, y) <> "" Then
                    list.Range(list.Cells(nextRow, 11), list.Cells(nextRow, 13)).Value = _
                        .Range(.Cells(x, y - 2), .Cells(x, y)).Value
                    nextRow = nextRow + 1
                End If
            Next y
        Next x
        
    End With
End Sub

This will place them on a new sheet, ensuring data integrity.
 
Upvote 0

Forum statistics

Threads
1,214,935
Messages
6,122,337
Members
449,078
Latest member
skydd

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top