Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Concatenate UDF help please

Hi

I need some help creating a UDF that concatenates a RANGE of cells as
follows:-

1. If the cell is BLANK, do not concatenate it
2. If the cell is NOT blank, add a BULLET and SPACE to the start of
the text, concatenate it and add a <CR to the end.

This is to create a bulleted list of non-blank cells in a range, with
a <CR between each entry.

so if the range (a single column of data) looks like:

<blank
hello world
<blank
<blank
more data
<blank
end
<blank

I would end up with a text string as follows:

— hello world
— more data
— end

Can anyone please help?

Many Thanks in advance...

NR

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Concatenate UDF help please

Function splice_um(rr As Range) As String
Dim s As String
s = ""
bullet = ". "
cr = Chr(10)
For Each r In rr
If Not IsEmpty(r) Then
s = s & bullet & r.Value & cr
End If
Next
splice_um = s
End Function

Used a period for a bullet. Text wrapping must be on to see the column.
--
Gary''s Student - gsnu200721
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Concatenate UDF help please

On May 14, 5:47 pm, Gary''s Student <snip wrote some good code:

Gary''s Student - gsnu200721


Perfect - thanks so much

:oş

NR

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Concatenate UDF help please

Try this. Assume data is in column A

Sub merge_cells()

Lastrow = Cells(Rows.Count, "A").End(xlUp).Row

ConcatenateWord = ""
RowCount = 1
For NextRow = 2 To Lastrow

If IsEmpty(Cells(NextRow, "A")) Then

If ConcatenateWord < "" Then

Cells(RowCount, "A") = "€¢ " + ConcatenateWord
RowCount = RowCount + 1
ConcatenateWord = ""
End If
Else
ConcatenateWord = ConcatenateWord + " " + Cells(NextRow, "A")
Cells(NextRow, "A") = ""
End If

Next NextRow

If ConcatenateWord < "" Then
Cells(RowCount, "A") = "€¢ " + ConcatenateWord
End If


End Sub



"N Ramsay" wrote:

Hi

I need some help creating a UDF that concatenates a RANGE of cells as
follows:-

1. If the cell is BLANK, do not concatenate it
2. If the cell is NOT blank, add a BULLET and SPACE to the start of
the text, concatenate it and add a <CR to the end.

This is to create a bulleted list of non-blank cells in a range, with
a <CR between each entry.

so if the range (a single column of data) looks like:

<blank
hello world
<blank
<blank
more data
<blank
end
<blank

I would end up with a text string as follows:

— hello world
— more data
— end

Can anyone please help?

Many Thanks in advance...

NR


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
How to concatenate D1:D64? Joe User[_2_] Excel Discussion (Misc queries) 2 February 8th 10 10:31 AM
concatenate terri Excel Worksheet Functions 3 June 13th 08 09:52 PM
Concatenate naja Excel Discussion (Misc queries) 3 June 9th 08 08:15 PM
Concatenate Sheriff Excel Worksheet Functions 1 May 25th 08 11:07 AM
I know how to concatenate ,can one de-concatenate to split date? QUICK BOOKS PROBLEM- New Users to Excel 1 July 26th 05 05:07 PM


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