Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 536
Default Concatenate a row that is selected and include blank cells

Can this neat little snippet be altered to work on a row of selected cells AND include the blanks?

Works fine as is with =ConcatMe("A1:Z1") but omits any blanks.

I may want only A1:G1 including the blank cells if any. =ConcatMe('Selection')

Thanks,
Howard

Option Explicit

Function ConcatMe(Rng As Range) As String

Dim cl As Range

ConcatMe = ""

For Each cl In Rng
ConcatMe = ConcatMe & cl.Text
Next cl

End Function
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default Concatenate a row that is selected and include blank cells

hi Howard,

Function ConcatMe(Rng As Range) As String
Dim cl As Range
ConcatMe = ""
For Each cl In Rng
If cl = "" Then
ConcatMe = ConcatMe & " "
Else
ConcatMe = ConcatMe & cl.Text
End If
Next cl
End Function

isabelle

Le 2013-06-15 20:53, Howard a écrit :
Can this neat little snippet be altered to work on a row of selected cells AND include the blanks?

Works fine as is with =ConcatMe("A1:Z1") but omits any blanks.

I may want only A1:G1 including the blank cells if any. =ConcatMe('Selection')

Thanks,
Howard

Option Explicit

Function ConcatMe(Rng As Range) As String

Dim cl As Range

ConcatMe = ""

For Each cl In Rng
ConcatMe = ConcatMe & cl.Text
Next cl

End Function

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 536
Default Concatenate a row that is selected and include blank cells

On Saturday, June 15, 2013 6:08:26 PM UTC-7, isabelle wrote:
hi Howard,



Function ConcatMe(Rng As Range) As String

Dim cl As Range

ConcatMe = ""

For Each cl In Rng

If cl = "" Then

ConcatMe = ConcatMe & " "

Else

ConcatMe = ConcatMe & cl.Text

End If

Next cl

End Function



isabelle


Thanks, isabelle, just what I was looking for.

Regards,
Howard
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 536
Default Concatenate a row that is selected and include blank cells

On Saturday, June 15, 2013 8:54:26 PM UTC-7, Howard wrote:
On Saturday, June 15, 2013 6:08:26 PM UTC-7, isabelle wrote:

hi Howard,








Function ConcatMe(Rng As Range) As String




Dim cl As Range




ConcatMe = ""




For Each cl In Rng




If cl = "" Then




ConcatMe = ConcatMe & " "




Else




ConcatMe = ConcatMe & cl.Text




End If




Next cl




End Function








isabelle




Thanks, isabelle, just what I was looking for.



Regards,

Howard


Well, drat! I should have seen this before I posted.
I want to select a variable range of cells in a row and while selected run this little macro.

Sub ConCatAK_15()
Range("AK15").Formula = "=ConcatMe(A1:H1)"
End Sub

So AK15 would then be =ConcatMe(what I selected)

I don't know what to Dim and set as the selection...?
Dim xxx as Selection and then Range("AK15").Formula = "=ConcatMe(xxx)"

Howard
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Concatenate a row that is selected and include blank cells

Hi Howard,

Am Sat, 15 Jun 2013 21:27:30 -0700 (PDT) schrieb Howard:

Well, drat! I should have seen this before I posted.
I want to select a variable range of cells in a row and while selected run this little macro.

Sub ConCatAK_15()
Range("AK15").Formula = "=ConcatMe(A1:H1)"
End Sub


if you want to concatenate A and activecell.row: H and Activecell.row
try:
Sub ConcatMe()
Dim rngC As Range
With ActiveCell
For Each rngC In Range(Cells(.Row, 1), Cells(.Row, 8))
[AK15] = [AK15] & rngC.Text
Next
End With
End Sub

if you only want to concatenate your selected cells try:

Sub ConcatMe2()
Dim rngC As Range

For Each rngC In Selection
[AK15] = [AK15] & rngC.Text
Next
End Sub


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 536
Default Concatenate a row that is selected and include blank cells

This second one is what I had in mind. I struggled with a macro that did similar to what you posted EXCEPT it returned everything in reverse and would not include the blank cells. What I will use this for is single common words where there will be no blanks, but also on proper names like Henry the Eighth or Henry Wadsworth Longfellow or King Tut.

K i n g T u t so will need to include the blank/space cell.

Howard

if you only want to concatenate your selected cells try:

Sub ConcatMe2()
Dim rngC As Range

For Each rngC In Selection
[AK15] = [AK15] & rngC.Text
Next
End Sub
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
Filters will not include cells beyond the first blank? stuckatCU Excel Discussion (Misc queries) 2 May 22nd 09 07:49 PM
OFFSET to include blank cells GMCN Excel Worksheet Functions 2 April 3rd 06 10:11 AM
Macro to concatenate previously selected cells Grumpy Excel Programming 1 November 22nd 05 02:42 PM
blank cells that include text Cally Excel Worksheet Functions 3 November 5th 04 01:01 AM
Moving between a cell that is selected to include a range of cells in that row kls[_2_] Excel Programming 0 September 30th 04 12:14 AM


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