Combining Two Cells.

S

Sam

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
 
B

Barb Reinhardt

= B1 & " " & A1

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

Tom Ogilvy

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top