Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Multi Line Transpose Excel VBA code

I have data that is listed in one long vertical column:

ADAM1
ADAM2
ADAM3
ADAM4
ADAM5
BOAT1
BOAT2
BOAT3
BOAT4
BOAT5

the listings of the "ADAM" and "BOAT" is always 5.
I'm showing two (ADAM and BOAT) in this example, but in my reality
there are thousands.`

I need some code to move this data into horizontal cells like this:

ADAM1 ADAM2 ADAM3 ADAM4 ADAM5
BOAT1 BOAT2 BOAT3 BOAT4 BOAT5

Can someone get me started...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Multi Line Transpose Excel VBA code

Sub macro1()
Dim iCt As Long
Dim iCol As Long
Dim iRow As Long
Set ws = Sheets("Sheet1")
iCol = 2
iCt = 1
iRow = 1
Do Until ws.Cells(iCt, 1) = ""
ws.Cells(iRow, iCol) = ws.Cells(iCt, 1)
If iCt Mod 5 = 0 Then
iRow = iRow + 1
iCol = 1
End If
iCol = iCol + 1
iCt = iCt + 1
Loop
End Sub

Hth,
Merjet

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Multi Line Transpose Excel VBA code

A couple of small tweaks below to get it to run in my environment.
It works great!!!
Thanks


Sub macro1()
Dim iCt As Long
Dim iCol As Long
Dim iRow As Long

iCol = 2
iCt = 1
iRow = 1
Do Until Sheet1.Cells(iCt, 1) = ""
Sheet1.Cells(iRow, iCol) = Sheet1.Cells(iCt, 1)
If iCt Mod 5 = 0 Then
iRow = iRow + 1
iCol = 1
End If
iCol = iCol + 1
iCt = iCt + 1
Loop
End Sub
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Multi Line Transpose Excel VBA code

Using a worksheet function enter this in B1 and copy across to F1

=INDEX($A:$A,(ROWS($1:1)-1)*5+COLUMNS($A:B)-1)

Select B1:F1 and copy down until you get zeros.

I know it's not code but it is one method.


Gord Dibben MS Excel MVP

On Tue, 11 Dec 2007 15:47:06 -0800 (PST), wrote:

I have data that is listed in one long vertical column:

ADAM1
ADAM2
ADAM3
ADAM4
ADAM5
BOAT1
BOAT2
BOAT3
BOAT4
BOAT5

the listings of the "ADAM" and "BOAT" is always 5.
I'm showing two (ADAM and BOAT) in this example, but in my reality
there are thousands.`

I need some code to move this data into horizontal cells like this:

ADAM1 ADAM2 ADAM3 ADAM4 ADAM5
BOAT1 BOAT2 BOAT3 BOAT4 BOAT5

Can someone get me started...


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
Concatenate: Multi-Line Cell with 2 single line cells BEEJAY Excel Worksheet Functions 0 February 15th 07 08:53 PM
Creating a multi dimensional array using transpose - Is this the best answer? [email protected] Excel Programming 11 July 19th 06 05:28 PM
macro code for grouping adjacent cells into one multi-line cel M John Excel Programming 2 November 30th 05 04:11 PM
macro code for grouping adjacent cells into one multi-line cel M John Excel Programming 0 November 29th 05 11:54 PM
how can I paste multi-line/multi-paragraph data into ONE cell? Theano Excel Discussion (Misc queries) 3 June 7th 05 01:10 PM


All times are GMT +1. The time now is 11:50 PM.

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

About Us

"It's about Microsoft Excel"