#1   Report Post  
Posted to microsoft.public.excel.misc
GARY
 
Posts: n/a
Default TRANSPOSING

Column A contains 'blocks' of either 7 or 8 cells. For example:

0CLOTHESTIME STORE INC

C/O GENERAL ACCTG

5325 E HUNTER AVE 03/15/2006

ANAHEIM CA 92807

215.99
217.99
0 200301234 2003-2004 004-018
000027991-8
0
2003-2004
0CROCKER, JAMES R & BARBARA J

41398 SHADOW MOUNTAIN WY

HEMET CA 92544 03/15/2006

51.45
51.95
0 200301244 2003-2004 006-165
000028278-1
0
2004-2005

The first cell in each 'block' contains, in the two leftmost positions,
a '0' (zero) and a non-space character. For example:

The first cell of the first 'block' contains: 0CLOTHESTIME STORE
INC
The first cell of the second 'block' contains: 0CROCKER, JAMES R &
BARBARA J

I need to tranpose the cells of each block. But how do I accomodate
the varying number of cells in each 'block'?

  #2   Report Post  
Posted to microsoft.public.excel.misc
Stefi
 
Posts: n/a
Default TRANSPOSING

Hi Gary,

Try this macro solution (from your example I assumed that row 5 is missing
from the 7 row blocks and you copy from "Sheet1" to "Sheet2"):

Sub trpose()
headrow = 1
lastrow = 0
blockcounter = 0
Do While blocklength(headrow, lastrow) 0
blockcounter = blockcounter + 1
If lastrow - headrow = 6 Then
Range("A" & headrow + 4).Select
Selection.EntireRow.Insert
lastrow = lastrow + 1
End If
' MsgBox (headrow & "-" & lastrow)
Range("A" & headrow & ":A" & lastrow).Select
Selection.Copy
Worksheets("Sheet2").Activate
Range("A" & blockcounter).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=True
Worksheets("Sheet1").Activate
headrow = lastrow + 1
Loop
Application.CutCopyMode = False
End Sub
Function headid(headcell)
headid = Left(headcell, 1) = "0" _
And Mid(headcell, 2, 3) = " " _
And IsNumeric(Mid(headcell, 5, 4)) _
And Mid(headcell, 9, 1) = "-" _
And IsNumeric(Mid(headcell, 10, 4))
End Function
Function blocklength(thisheadrow, lastblockrow)
notheadrows = thisheadrow + 7
Do Until headid(Range("A" & notheadrows)) Or IsEmpty(Range("A" &
notheadrows))
notheadrows = notheadrows + 1
Loop
lastblockrow = notheadrows - 1
nextheadrow = notheadrows
blocklength = IIf(IsEmpty(Range("A" & thisheadrow)), 0, nextheadrow -
thisheadrow)
End Function


Sorry if testing is not perfect!

Regards,
Stefi

€˛GARY€¯ ezt Ć*rta:

Column A contains 'blocks' of either 7 or 8 cells. For example:

0CLOTHESTIME STORE INC

C/O GENERAL ACCTG

5325 E HUNTER AVE 03/15/2006

ANAHEIM CA 92807

215.99
217.99
0 200301234 2003-2004 004-018
000027991-8
0
2003-2004
0CROCKER, JAMES R & BARBARA J

41398 SHADOW MOUNTAIN WY

HEMET CA 92544 03/15/2006

51.45
51.95
0 200301244 2003-2004 006-165
000028278-1
0
2004-2005

The first cell in each 'block' contains, in the two leftmost positions,
a '0' (zero) and a non-space character. For example:

The first cell of the first 'block' contains: 0CLOTHESTIME STORE
INC
The first cell of the second 'block' contains: 0CROCKER, JAMES R &
BARBARA J

I need to tranpose the cells of each block. But how do I accomodate
the varying number of cells in each 'block'?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
updating chart source after transposing rows Lynne Charts and Charting in Excel 0 February 1st 06 10:56 AM
transposing links BorisS Excel Worksheet Functions 9 November 12th 05 03:31 PM
Advanced Transposing? SHexceluser Excel Worksheet Functions 0 October 12th 05 03:55 PM
Transposing a column to several rows [email protected] Excel Worksheet Functions 4 May 26th 05 09:06 PM
merging and transposing cells Daniel M Excel Worksheet Functions 3 February 20th 05 09:56 AM


All times are GMT +1. The time now is 09:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"