I get what this is doing basically, but haven't really done anything
like this in Excel before, so I don't actually know how I am supposed
to utilize the code.
I have two sheets the source sheet is called Labels and the starting
cell is A1. The desitnation sheet is called list and the starting cell
would be A1.
Where would I put the code to make it work?
JLatham Wrote:
> This code doesn't care how many rows make up an address, 1, 2, 4, 10 -
> it
[quoted text clipped - 86 lines]
>
> Mary

Signature
lucrezia
JLatham - 20 Oct 2006 02:40 GMT
Revised code with your sheet names in it:
Sub TransposeGroups()
Dim SRange As Range ' source range
Dim DRange As Range ' destination range
Dim SourceRO As Long ' SourceRowOffset
Dim DestRO As Long ' destination row offset
Dim DestCO As Integer ' destination column offset
Dim LRTC As Long 'last row to check
'
'define SRange and DRange for your workbook
'
Set SRange = Worksheets("Labels").Range("A1")
Set DRange = Worksheets("list").Range("A1")
'
'match sheet name here with source sheet to be used
'
LRTC = _
Worksheets("Labels").Range("A" & Rows.Count).End(xlUp).Row
Do Until SourceRO LRTC
If Not IsEmpty(SRange.Offset(SourceRO, 0)) Then
DRange.Offset(DestRO, DestCO) = _
SRange.Offset(SourceRO, 0)
DestCO = DestCO + 1
Else
'empty cell, update pointers
DestCO = 0
If Not (IsEmpty(DRange.Offset(DestRO, DestCO))) Then
DestRO = DestRO + 1
End If
End If
SourceRO = SourceRO + 1
Loop
End Sub
Just copy that and paste into a code module in the Excel workbook. To get
to where you need to paste it, open the workbook and use [Alt]+[F11] to open
the VB Editor. If the big area is gray, use [Alt]+[I] followed by [M] to
Insert a new Module. Just paste the code into there and close the VB Editor.
Go to Tools | Macros | Macro and highlight the one named TransposeGroups and
hit the [Run] button. Should take about as long as it takes you to say wow
to work unless there are a heck of a lot of entries on the source sheet.
> I get what this is doing basically, but haven't really done anything
> like this in Excel before, so I don't actually know how I am supposed
[quoted text clipped - 97 lines]
> >
> > Mary
JLatham - 20 Oct 2006 02:45 GMT
Copying and messing with the code to set it up for your workbook hosed up one
of the lines of code, or so it seems in my preview, so here it is again - the
line of code changed is
Do Until SourceRO > LRTC
looks like I lost the > symbol somewhere in translation. Also, lines that
end with a space and the underscore character ( _) are actually lines that
are continued on the next line. They should work with copy and paste just
fine unless an extra character gets added after the underscore character.
Sub TransposeGroups()
Dim SRange As Range ' source range
Dim DRange As Range ' destination range
Dim SourceRO As Long ' SourceRowOffset
Dim DestRO As Long ' destination row offset
Dim DestCO As Integer ' destination column offset
Dim LRTC As Long 'last row to check
'
'define SRange and DRange for your workbook
'
Set SRange = Worksheets("Labels").Range("A1")
Set DRange = Worksheets("list").Range("A1")
'
'match sheet name here with source sheet to be used
'
LRTC = _
Worksheets("Labels").Range("A" & Rows.Count).End(xlUp).Row
Do Until SourceRO > LRTC
If Not IsEmpty(SRange.Offset(SourceRO, 0)) Then
DRange.Offset(DestRO, DestCO) = _
SRange.Offset(SourceRO, 0)
DestCO = DestCO + 1
Else
'empty cell, update pointers
DestCO = 0
If Not (IsEmpty(DRange.Offset(DestRO, DestCO))) Then
DestRO = DestRO + 1
End If
End If
SourceRO = SourceRO + 1
Loop
End Sub
> I get what this is doing basically, but haven't really done anything
> like this in Excel before, so I don't actually know how I am supposed
[quoted text clipped - 97 lines]
> >
> > Mary