View Single Post
  #18   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default How do I merge two cells without deleting data from the cell?

You cannot concatenate a range of cells using the Excel CONCATENATE
function.

Either =CONCATENATE(K2,L2,M2) etc. or =K2&L2&M2 etc.

or a 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 & " "
' the " " returns space-delimited text
Next
ConCatRange = Left(sbuf, Len(sbuf) - 1)
End Function

Usage is: =ConCatRange(K2:KZ2)

If you're not familiar with VBA and macros/functions, see David McRitchie's
site for more on "getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

or Ron de De Bruin's site on where to store macros.

http://www.rondebruin.nl/code.htm

In the meantime..........

First...create a backup copy of your original workbook.

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + r to open Project Explorer.

Find your workbook/project and select it.

Right-click and InsertModule. Paste the code in there. Save the
workbook and hit ALT + Q to return to your workbook.

In a cell enter the formula as shown above in Usage is:


Gord Dibben MS Excel MVP


On Sun, 10 Aug 2008 08:49:00 -0700, anthony561fl
wrote:

Im still stuck on trying to concatenate a wide range of cells. I tried the
formula
=concatrange(K2:KZ2)
but get the following:
#NAME?

When I try to search help for concatrange, nothing comes up, only
concatenate.

Could you clarify more for me please? Thank you.




"roshni" wrote:


Thank you so much for sending me this formula.I really appreciate your
quick, helpful response.

Sincerely,
roshni
"Batmans_Wife" wrote:

I'm highlighting two cells in the same row, hitting format cells, alignment,
merge cells and I'm getting the error message, "The selection contains
multiple data values. Merging into one cell will keep the upper-left most
data only." I want to be able to make the two seperate cells one without
deleting anything and without having to cut and paste.