Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default merging ranges

I have two ranges. One with last names and one with first names. I want to
take those two ranges and make them one new range. i want that new range to
look like lastname, firstname. I would think this is very simple to do. I
have been trying but i can't get it to work.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default merging ranges

Lastnames in column A
Firstnames in column B
Put the joined names in Column C

Dim rng as Range, cell as Range
set rng = Range(Cells(1,1),Cells(1,1).End(xldown)
for each cell in rng
cell.offset(0,2).Value = cell.value & ", " & cell.offset(0,1).Value
Next

a formula: in C1

=trim(A1) & ", " & trim(B1)

then drag fill down the column

Same approach in code:
Dim rng as Range, cell as Range
set rng = Range(Cells(1,1),Cells(1,1).End(xldown)
rng.offset(0,2).Formula = "=trim(A1) & "", "" & trim(B1)"
'replace the formula with its results.
rng.offset(0,2).Formula = rng.Offset(0,2).Value


--
Regards,
Tom Ogilvy

"Rich Cooper" wrote in message
...
I have two ranges. One with last names and one with first names. I want

to
take those two ranges and make them one new range. i want that new range

to
look like lastname, firstname. I would think this is very simple to do.

I
have been trying but i can't get it to work.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how copy formula that contains ranges so ranges do not overlap Patty Excel Worksheet Functions 1 November 20th 08 04:15 PM
Merging Sharlene Excel Discussion (Misc queries) 1 July 14th 06 01:05 AM
When merging information not merging correctly Bridgett Excel Worksheet Functions 0 December 9th 05 10:12 PM
Sorting, Merging, and Re-merging Abi Excel Worksheet Functions 2 June 15th 05 08:21 PM
named ranges - changing ranges with month selected gr8guy Excel Programming 2 May 28th 04 04:50 AM


All times are GMT +1. The time now is 02:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"