Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Merge Cells depending on another column


Hi All

Need some urgent help

i have worksheet with the following format

1111 abc
1111 xyz
1234 qwe

I need help to merge column b values depending on column A.If two rows
have the same value in column a then i would like to merge column b as
shown below.
So i need the above data to appear as

1111 abc,xyz
1234 qwe

thanks
sp123


--
sp123
------------------------------------------------------------------------
sp123's Profile: http://www.excelforum.com/member.php...o&userid=31163
View this thread: http://www.excelforum.com/showthread...hreadid=521943

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Merge Cells depending on another column

Try this against a copy of your worksheet--it destroys the original data when it
builds the output:

Option Explicit
Sub testme()
Dim iRow As Long
Dim LastRow As Long
Dim FirstRow As Long
Dim wks As Worksheet

Set wks = Worksheets("Sheet1")

With wks
FirstRow = 1
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For iRow = LastRow To FirstRow + 1 Step -1
If .Cells(iRow, "A").Value = .Cells(iRow - 1, "A").Value Then
.Cells(iRow - 1, "B").Value _
= .Cells(iRow - 1, "B").Value _
& "," & .Cells(iRow, "B").Value
.Rows(iRow).Delete
End If
Next iRow
End With
End Sub

And make sure your data is sorted by column A.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

sp123 wrote:

Hi All

Need some urgent help

i have worksheet with the following format

1111 abc
1111 xyz
1234 qwe

I need help to merge column b values depending on column A.If two rows
have the same value in column a then i would like to merge column b as
shown below.
So i need the above data to appear as

1111 abc,xyz
1234 qwe

thanks
sp123

--
sp123
------------------------------------------------------------------------
sp123's Profile: http://www.excelforum.com/member.php...o&userid=31163
View this thread: http://www.excelforum.com/showthread...hreadid=521943


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Merge Cells depending on another column


Can Pls modify the function so that the result would appear on separat
cells instead of being separated by commas

Something like this

1111 abc xyz
1234 qw

--
sp12
-----------------------------------------------------------------------
sp123's Profile: http://www.excelforum.com/member.php...fo&userid=3116
View this thread: http://www.excelforum.com/showthread.php?threadid=52194

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
Counting Cells in a column depending on another column but excluding duplicates rwenger Excel Discussion (Misc queries) 0 April 11th 10 01:06 PM
Add cells in column depending on value of cells in another column CDBallard Excel Discussion (Misc queries) 1 July 10th 07 03:12 PM
Merge Rows depending on value of the first column sp123 Excel Worksheet Functions 1 April 20th 06 03:43 AM
How do I merge two cells in a column AliWitt Excel Discussion (Misc queries) 1 February 9th 06 10:37 PM
Merge Cells in a column Macro Mike G. Excel Programming 1 May 18th 04 05:34 PM


All times are GMT +1. The time now is 02:07 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"