ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Combining Two Cells. (https://www.excelbanter.com/excel-programming/390107-combining-two-cells.html)

Sam

Combining Two Cells.
 
Hi ...

Some months ago I posted a question here, and someone was kind enough to
show me how to write the code to do what I needed. Unfortunately, I'm not a
good student and need a refresher.

Now, I know it's easy to combine two cells into one if you know what they
are, but what I have in mind is combining two cells on the fly, so to speak.

A1 ---------- B1
_____________
Company --- Bud's

I want to combine them so cell BI reads, `Bud's Company,' and cell A1 is
empty. I want the user to be able to do this operation easily, maybe just
pressing a `hot key' (CTRL-M, say) to accomplish it.

I have tried to reconstruct the code that some from this newsgroup did for
me, but I can't quite get it to work.

Appreciate any help.

Sam



Barb Reinhardt

Combining Two Cells.
 
= B1 & " " & A1

If you are entering it as formula try
Range("C1").FormulaR1C1 = "=B1 & "" "" & A1"


"Sam" wrote:

Hi ...

Some months ago I posted a question here, and someone was kind enough to
show me how to write the code to do what I needed. Unfortunately, I'm not a
good student and need a refresher.

Now, I know it's easy to combine two cells into one if you know what they
are, but what I have in mind is combining two cells on the fly, so to speak.

A1 ---------- B1
_____________
Company --- Bud's

I want to combine them so cell BI reads, `Bud's Company,' and cell A1 is
empty. I want the user to be able to do this operation easily, maybe just
pressing a `hot key' (CTRL-M, say) to accomplish it.

I have tried to reconstruct the code that some from this newsgroup did for
me, but I can't quite get it to work.

Appreciate any help.

Sam




Tom Ogilvy

Combining Two Cells.
 
Sub CombineCells()
if activecell.column = 1 then exit sub
activecell.value = activeCell.Text & " " & _
activecell.offset(0,-1).Text
activecell.offset(0,-1).clearContents
End Sub

put it in a general module.

Then go back to excel and do Tools=Macro=Macros

select combinecells and click the options button. Assign a shortcut.

--
Regards,
Tom Ogilvy

"Sam" wrote in message
news:Blq5i.11464$xP.9277@trndny04...
Hi ...

Some months ago I posted a question here, and someone was kind enough to
show me how to write the code to do what I needed. Unfortunately, I'm not
a good student and need a refresher.

Now, I know it's easy to combine two cells into one if you know what they
are, but what I have in mind is combining two cells on the fly, so to
speak.

A1 ---------- B1
_____________
Company --- Bud's

I want to combine them so cell BI reads, `Bud's Company,' and cell A1 is
empty. I want the user to be able to do this operation easily, maybe just
pressing a `hot key' (CTRL-M, say) to accomplish it.

I have tried to reconstruct the code that some from this newsgroup did for
me, but I can't quite get it to work.

Appreciate any help.

Sam




Sam

Combining Two Cells.
 
Thanks, Barb and Tom!




All times are GMT +1. The time now is 09:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com