![]() |
Macro to combine cells
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. -- c mcg ------------------------------------------------------------------------ c mcg's Profile: http://www.excelforum.com/member.php...o&userid=33560 View this thread: http://www.excelforum.com/showthread...hreadid=533465 |
Macro to combine cells
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" wrote in message ... 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. -- c mcg ------------------------------------------------------------------------ c mcg's Profile: http://www.excelforum.com/member.php...o&userid=33560 View this thread: http://www.excelforum.com/showthread...hreadid=533465 |
Macro to combine cells
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. -- c mcg ------------------------------------------------------------------------ c mcg's Profile: http://www.excelforum.com/member.php...o&userid=33560 View this thread: http://www.excelforum.com/showthread...hreadid=533465 |
Macro to combine cells
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 "c mcg" wrote in message ... 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. -- c mcg ------------------------------------------------------------------------ c mcg's Profile: http://www.excelforum.com/member.php...o&userid=33560 View this thread: http://www.excelforum.com/showthread...hreadid=533465 |
All times are GMT +1. The time now is 07:45 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com