Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Concatenate text from columns

How can I concatenate text in colB?
ColA has 2 markers C and *
Whenever C is followed by * I need to unite the text fields in ColB
So, for the data below I want
ColA ColB
C Text1 Text1a
C Text2 Text2a Text2b Text2c

ColA ColB
C Text1
* Text1a cont'd
C Text2
* Text2a cont'd
* Text2b cont'd
* Text2c cont'd
C Text3

Hope this makes sense!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Concatenate text from columns


Thbe easy method is to use a fromula in the worksheet. Something like
this in cell C1

=if(A2="*",B1&B2,"")


Then copy formula down column C

Next Copy column C and PasteSpecial using Values.

Finally sort sheet using column A. The rows with column A = C are the
final results

Sub Combinerows()

LastRow = Range("A" & Rows.Count).End(xlUp).Row

Range("C1").Formula = "=if(A2=" * ",B1&B2,"")"
Range("C1").Copy _
Destination:=Range("C1:C" & LastRow)

Range("C1:C" & LastRow).Copy
Range("C1:C" & LastRow).PasteSpecial Paste:=xlPasteValues

Rows("1:" & LastRow).Sort _
Header:=xlNo, _
Key1:=Range("A1"), _
order1:=xlAscending

End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=158503

Microsoft Office Help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Concatenate text from columns

Try this:

=======
Sub MergeTexts()
'JBeaucaire (12/1/2009)
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
i = 2

Do Until Len(Range("A" & i)) = 0
If Range("A" & i) = "*" And Range("A" & i - 1) = "C" Then
Range("B" & i - 1) = Range("B" & i - 1) & " " & Range("B" & i)
Rows(i).Delete xlShiftUp
Else
i = i + 1
End If
Loop

End Sub
========

--
"Actually, I *am* a rocket scientist." -- JB
(www.MadRocketScientist.com)

Your feedback is appreciated, click YES if this post helped you.


"Saintsman" wrote:

How can I concatenate text in colB?
ColA has 2 markers C and *
Whenever C is followed by * I need to unite the text fields in ColB
So, for the data below I want
ColA ColB
C Text1 Text1a
C Text2 Text2a Text2b Text2c

ColA ColB
C Text1
* Text1a cont'd
C Text2
* Text2a cont'd
* Text2b cont'd
* Text2c cont'd
C Text3

Hope this makes sense!

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
combining columns and using concatenate Donna[_2_] Excel Worksheet Functions 5 April 21st 10 12:46 AM
CONCATENATE TWO COLUMNS The Cable Guy Excel Worksheet Functions 3 December 16th 09 04:37 AM
Concatenate two columns? uma Excel Worksheet Functions 1 April 19th 06 09:46 AM
Concatenate 3 columns. Jim15[_12_] Excel Programming 0 February 23rd 06 05:08 PM
Concatenate 3 columns. Jim15[_13_] Excel Programming 0 February 23rd 06 05:00 PM


All times are GMT +1. The time now is 02:04 AM.

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"