#1   Report Post  
Posted to microsoft.public.excel.misc
FIRSTROUNDKO via OfficeKB.com
 
Posts: n/a
Default Concatenate Loop

Hi!

I have two collums of data

CAR
BUS
1 TRAIN
PLANE
2 MOTORBIKE
SCOOTER
HELICOPTER
3 TRAM

I would like to run a loop which concatenated my data based upon the first
collumn (as below)

CAR
BUS
1 TRAIN CARBUSTRAIN
PLANE
2 MOTORBIKE PLANEMOTORBIKE
SCOOTER
HELICOPTER
3 TRAM SCOOTERHELICOPTERTRAM

Thanks in advance

Darren

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200603/1
  #2   Report Post  
Posted to microsoft.public.excel.misc
Ardus Petus
 
Posts: n/a
Default Concatenate Loop

This will need some VBA macro code. Do you mind?

--
AP

"FIRSTROUNDKO via OfficeKB.com" <u15639@uwe a écrit dans le message de
news:5d0de6d2c58e7@uwe...
Hi!

I have two collums of data

CAR
BUS
1 TRAIN
PLANE
2 MOTORBIKE
SCOOTER
HELICOPTER
3 TRAM

I would like to run a loop which concatenated my data based upon the first
collumn (as below)

CAR
BUS
1 TRAIN CARBUSTRAIN
PLANE
2 MOTORBIKE PLANEMOTORBIKE
SCOOTER
HELICOPTER
3 TRAM SCOOTERHELICOPTERTRAM

Thanks in advance

Darren

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200603/1



  #3   Report Post  
Posted to microsoft.public.excel.misc
FIRSTROUNDKO via OfficeKB.com
 
Posts: n/a
Default Concatenate Loop

Ardus,

that would be just great.

Darren

Ardus Petus wrote:
This will need some VBA macro code. Do you mind?

--
AP

Hi!

[quoted text clipped - 24 lines]

Darren


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200603/1
  #4   Report Post  
Posted to microsoft.public.excel.misc
Ardus Petus
 
Posts: n/a
Default Concatenate Loop

Paste following code in a Module:

'-------------------------------------
Sub concat()
'Cell address of 1st vehicle to be processed
Const strFirstVehicle = "B1"
'assume rank is one column to the left
'and result one column to the right
Dim rng As Range
Dim strResult As String

'Initialize
strRsult = ""
Set rng = Range(strFirstVehicle)

'Loop
Do While rng.Value < ""
strResult = strResult & rng.Value
If rng.Offset(0, -1).Value < "" Then
rng.Offset(0, 1) = strResult
strResult = ""
End If
Set rng = rng.Offset(1, 0)
Loop
End Sub
'----------------------------------------

HTH
--
AP

"FIRSTROUNDKO via OfficeKB.com" <u15639@uwe a écrit dans le message de
news:5d0fe78795c9f@uwe...
Ardus,

that would be just great.

Darren

Ardus Petus wrote:
This will need some VBA macro code. Do you mind?

--
AP

Hi!

[quoted text clipped - 24 lines]

Darren


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200603/1



  #5   Report Post  
Posted to microsoft.public.excel.misc
FIRSTROUNDKO via OfficeKB.com
 
Posts: n/a
Default Concatenate Loop

AP,

Thats just awesome

Thanks

Darren


Ardus Petus wrote:
Paste following code in a Module:

'-------------------------------------
Sub concat()
'Cell address of 1st vehicle to be processed
Const strFirstVehicle = "B1"
'assume rank is one column to the left
'and result one column to the right
Dim rng As Range
Dim strResult As String

'Initialize
strRsult = ""
Set rng = Range(strFirstVehicle)

'Loop
Do While rng.Value < ""
strResult = strResult & rng.Value
If rng.Offset(0, -1).Value < "" Then
rng.Offset(0, 1) = strResult
strResult = ""
End If
Set rng = rng.Offset(1, 0)
Loop
End Sub
'----------------------------------------

HTH
--
AP

Ardus,

[quoted text clipped - 12 lines]

Darren


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200603/1
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
Loop gone crazy Dave Peterson Excel Discussion (Misc queries) 4 December 16th 05 03:38 PM
Do Loop Noemi Excel Discussion (Misc queries) 0 December 8th 05 10:43 PM
Using Concatenate inside a vlookup bmclean Excel Worksheet Functions 3 July 5th 05 09:29 PM
VB for excel, how do I loop through code steve hobden via OfficeKB.com Excel Discussion (Misc queries) 2 June 9th 05 01:59 PM
Concatenate cells without specifying/writing cell address individually Hari Excel Discussion (Misc queries) 4 January 3rd 05 06:05 PM


All times are GMT +1. The time now is 11:44 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"