Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
MtK MtK is offline
external usenet poster
 
Posts: 1
Default trying to combine cells with shortest equation

So I have this equation that looks like

=C1&" "&C2&" "&C3&" "&C4&" "&C5

I was thinking maybe I could reduce the equation to just show the
first and last cell like =C1:C2 but that doesn't work and even if it
did i need the space between the two cells. and help are creating a
reduced equation that uses the first and last cells and has a space
would be greatly appreciated. thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default trying to combine cells with shortest equation

MtK

User defined Function.

Function ConCatRange(CellBlock As Range) As String
Dim cell As Range
Dim sbuf As String
For Each cell In CellBlock
If Len(cell.text) 0 Then sbuf = sbuf & cell.text & ","
Next
ConCatRange = Left(sbuf, Len(sbuf) - 1)
End Function

Usage is: =ConCatRange(C1:C5)

Macro.........

Sub ConCat_Cells()
Dim x As Range
Dim y As Range
Dim z As Range
Dim w As String
Dim sbuf As String
On Error GoTo endit
w = InputBox("Enter the Type of De-limiter Desired")
Set z = Application.InputBox("Select Destination Cell", _
"Destination Cell", , , , , , 8)
Application.SendKeys "+{F8}"
Set x = Application.InputBox("Select Cells...Contiguous or
Non-Contiguous", _
"Cells Selection", , , , , , 8)
For Each y In x
If Len(y.text) 0 Then sbuf = sbuf & y.text & w
Next
z = Left(sbuf, Len(sbuf) - 1)
'Application.SendKeys "+{F8}"
Exit Sub
endit:
MsgBox "Nothing Selected. Please try again."
End Sub

Watch for word-wrap. Note continuation marks "_"

Gord Dibben Excel MVP

On 23 Jun 2004 09:46:29 -0700, (MtK) wrote:

So I have this equation that looks like

=C1&" "&C2&" "&C3&" "&C4&" "&C5

I was thinking maybe I could reduce the equation to just show the
first and last cell like =C1:C2 but that doesn't work and even if it
did i need the space between the two cells. and help are creating a
reduced equation that uses the first and last cells and has a space
would be greatly appreciated. thanks.


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 do I use a cells from one worksheet in the equation of another mclwlg Excel Discussion (Misc queries) 2 April 16th 09 12:53 PM
Combine cells with the same reference and combine quantities brandon Excel Discussion (Misc queries) 2 September 17th 08 05:44 PM
Have problem in Manipulating Workbook Object and make macro shortest as possible Irmann Excel Worksheet Functions 0 February 5th 08 09:32 AM
=IF(AND) equation pulls through N/A cells Boethius1 Excel Discussion (Misc queries) 0 March 13th 06 08:43 PM
How to obtain the shortest range that encloses all the non empty cells? faustino Dina Excel Programming 2 August 2nd 03 05:25 PM


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