Macro to combine cells

  • Thread starter Thread starter c mcg
  • Start date Start date
C

c mcg

Hi Guys great forum

im trying to create a macro that combines data from cells at any point
in my spreadsheet.

for instance I want to combine 3 cells that have a name in i.e

A= MR
B= JOHN
C= SMITH

however i also to combine there addresses e.g x = 74 y = the z= green.

is there any type of vba that could perform this for me.

any help will be greatly appreciated.
 
I'm not entirely clear what you want, but the & operator combines
text strings. E.g.,

Dim Res As String
Res = Range("A1").Value & " " & Range("B1").Value & " " &
Range("C1").Value
MsgBox Res

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"c mcg" <[email protected]>
wrote in message
news:[email protected]...
 
Basicly I have a spreadsheet that has information on people in it.
columns A to C have a name broken down into 3 sections consisting of a
title, first name and surname. I then have in columns G, H, and I which
is an address that is broken into 3 sections consisting of door number,
street name and town.

I have to combine the data in these cells so that all information goes
into one cell. The thing is I have a spreadsheet of around 200 rows and
i need to run this on each row.

I previously had a macro to do this for me that a friend of mine who i
can no longer contact created for me but when i upgraded my computer i
lost it. as far as i know the macro moved any highlighted cells data to
the first highlighted column.

Sorry to be a bit vague and thanks for your help.
 
It's hard to tell what you want.

Do you want to set D1 to the following:
= A1 & " " & B1 & " " & C1

and then drag D1 down ~200 rows, so that Dn ends up being set to the
following for all n?
= An & " " & Bn & " " & Cn

And similarly for J, based on G, H, and I?

Or should all 6 fields be combined into a single cell? Or is it more
complicated? Are you looking to write code, so you can avoid the copying?

Naomi
 

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

Back
Top