Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Concatenating text cells in a row (No. of cells not fixed)

Hi,

I request you all to help me solve this problem.

I have an excel file with data in rows like following ;
A B
C D
1 This Is
Sample 2587
2 This Is
547
3 This 257
222
4 This Is
Sample text

Required Result

This is sample
This is
This
This is sample text

Is there a way that I can concatenate only the text cells and ignore
the numeric ones (Per Row).

The number of cells containing text are variable (but they are in
starting only)

I would be grateful for your help.

Regards

Ashish Sharma
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Concatenating text cells in a row (No. of cells not fixed)

Sorry for that look of the message. Can anybody tell me what
precautions to take before posting so that my data comes in perfect
look.

Regards
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Concatenating text cells in a row (No. of cells not fixed)

Give this User Defined Function (UDF) a try...

Function ConcatenateTextOnly(R As Range) As String
Dim C As Range
For Each C In R
If Not IsNumeric(C.Value) Then
If Len(ConcatenateTextOnly) 0 And Len(C.Value) 0 Then
ConcatenateTextOnly = ConcatenateTextOnly & " "
End If
ConcatenateTextOnly = ConcatenateTextOnly & C.Value
End If
Next
End Function

If you are not familiar with UDFs, press Alt+F11 to go to the VB editor,
click Insert/Module from the VB editor's menu bar and copy paste the above
function into the code window that appeared. That's it. Now go back to your
worksheet and put this in E1..

=ConcatenateTextOnly(A1:D1)

and copy down. You can use any contiguous range you want and the function
will ignore empty cells and numbers, but it will concatenate everything
else.

--
Rick (MVP - Excel)


"ashish128" wrote in message
...
Hi,

I request you all to help me solve this problem.

I have an excel file with data in rows like following ;
A B
C D
1 This Is
Sample 2587
2 This Is
547
3 This 257
222
4 This Is
Sample text

Required Result

This is sample
This is
This
This is sample text

Is there a way that I can concatenate only the text cells and ignore
the numeric ones (Per Row).

The number of cells containing text are variable (but they are in
starting only)

I would be grateful for your help.

Regards

Ashish Sharma


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Concatenating text cells in a row (No. of cells not fixed)

On Sep 4, 2:41*pm, "Rick Rothstein"
wrote:
Give this User Defined Function (UDF) a try...

Function ConcatenateTextOnly(R As Range) As String
* Dim C As Range
* For Each C In R
* * If Not IsNumeric(C.Value) Then
* * * If Len(ConcatenateTextOnly) 0 And Len(C.Value) 0 Then
* * * * ConcatenateTextOnly = ConcatenateTextOnly & " "
* * * End If
* * * ConcatenateTextOnly = ConcatenateTextOnly & C.Value
* * End If
* Next
End Function

If you are not familiar with UDFs, press Alt+F11 to go to the VB editor,
click Insert/Module from the VB editor's menu bar and copy paste the above
function into the code window that appeared. That's it. Now go back to your
worksheet and put this in E1..

=ConcatenateTextOnly(A1:D1)

and copy down. You can use any contiguous range you want and the function
will ignore empty cells and numbers, but it will concatenate everything
else.

--
Rick (MVP - Excel)

"ashish128" wrote in message

...



Hi,


I request you all to help me solve this problem.


I have an excel file with data in rows like following ;
* * A * * * * * * * * * * * * B
C * * * * * * * * * * * * D
1 This * * * * * * * * * * Is
Sample * * * * * * * * 2587
2 This * * * * * * * * * * Is
547
3 This * * * * * * * * * *257
222
4 This * * * * * * * * * * Is
Sample * * * * * * * * text


Required Result

This is sample
This is
This
This is sample text


Is there a way that I can concatenate only the text cells and ignore
the numeric ones (Per Row).


The number of cells containing text are variable (but they are in
starting only)


I would be grateful for your help.


Regards


Ashish Sharma- Hide quoted text -


- Show quoted text -


Thank you so much Rick. It works great.

Thanks again

Regards
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
Concatenating non adjacent cells Bob Freeman Excel Discussion (Misc queries) 2 January 29th 10 01:49 PM
Fill variable number of cells with a fixed text Robert[_30_] Excel Programming 1 July 11th 07 11:24 AM
Concatenating Cells jbenet Excel Discussion (Misc queries) 5 December 10th 05 09:51 AM
Moving, deleting, and concatenating text in cells. te_butts Excel Worksheet Functions 4 September 20th 05 05:56 PM
concatenating cells with their formats GDC Excel Worksheet Functions 3 June 20th 05 07:16 PM


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