PDA

View Full Version : Solved: Incrementing to next record



grichey
05-29-2008, 11:49 AM
I have a sheet with data going down column in the form
Name
Address
Street
City and State
white space
.
.
.
repeating. Some data has actually 2 Name lines so it's sometimes 4 sometimes 5 rows of data before the next white space. I'm trying to transpose them across columns B through F or whatever they happen to come out to.
How do I jump to the next set of data after I've transposed the first?


Option Explicit
Sub transposerecords()

Dim counter As Integer
Dim counter2 As Integer

counter = 1
counter2 = 1

Do

Range("A" & counter).Select
Selection.End(x1Down).copy
Range("B" & counter2).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, transpose:=True

' here I need to have counter jump past data just copied
'and pasted to top of next set of 4 or 5 rows to be transposed

counter2 = counter2 +1


Loop Until IsEmpty(counter.Offset(1, 0))

End sub

Bob Phillips
05-29-2008, 12:07 PM
Sub transposerecords()
Dim LastRow As Long
Dim EndAt As Long
Dim i As Long

With ActiveSheet

.Rows(1).Insert
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
EndAt = LastRow
For i = LastRow To 1 Step -1

If .Cells(i, "A").Value = "" Then

.Cells(i + 1, "A").Resize(EndAt - i).Copy
.Cells(i, "A").PasteSpecial Paste:=xlPasteValues, Transpose:=True
.Rows(i + 1).Resize(EndAt - i).Delete
EndAt = i - 1
End If
Next i
End With
End Sub

grichey
05-29-2008, 12:14 PM
danke