November 16, 2007 at 1:03 pm
I have a excel table that looks like this.
FirstName LastName
Address1
Address 2
I would like the excel sheet to be formatted like this:
FirstName LastName Address1 Address2
One row per record.
Is the a code that can modify my entire spread sheet?
Thanks in advanced..
January 17, 2008 at 8:59 am
Using your example, I presume you have
first name last name
address1
address2
first name last name
address1
address2 etc. Create a new worksheet called "newsheet" or the like and then open a module in Excel VBA (macros) and use something like
Sub ReSort
Dim x as Double
Dim y as Int
Dim z as Double
Dim LineCount as Double (or Int if not too many rows)
With ThisWorkbook.Sheets("name of original worksheet")
LineCount = .UsedRange.Rows.Count
y = 1
z = 1
For x = 1 to LineCount
ThisWorkbook.Sheets("newsheet").Cells(z, y).Value = .Cells(x, y).Value
y = y + 1
If y Mod 3 = 0 Then
y = 1
z = z + 1
End If
Next x
End With
End Sub
It may not be quite right but play around with it.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply