Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Concatenate cells in one column of value in another column is same

Hi

Sorry that I could not even name this problem properly.

Please see tables below. The requirement will be quite obvious. Know
how to do this manually but not sure programmatically.

Thanks for the help.

Best
Prasad


Data Structure Before Macro

Name Place Animal Thing Number
Pers1 US Lion Pen One
Pers1 US Lion Pencil Two
Pers2 UK Bull Mouse Five


Data Structure After Macro
Name Place Animal Thing Number
Pers1 US Lion Pen, Pencil One, Two
Pers2 UK Bull Mouse Five

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Concatenate cells in one column of value in another column is same

Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long
Dim iLastRow As Long

With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = iLastRow To 2 Step -1

If .Cells(i, TEST_COLUMN).Value = .Cells(i - 1,
TEST_COLUMN).Value Then

If .Cells(i, "B").Value < .Cells(i - 1, "B").Value Then

.Cells(i - 1, "B").Value = .Cells(i - 1, "B").Value & ",
" & _
.Cells(i, "B").Value
End If

If .Cells(i, "C").Value < .Cells(i - 1, "C").Value Then

.Cells(i - 1, "C").Value = .Cells(i - 1, "C").Value & ",
" & _
.Cells(i, "C").Value
End If

If .Cells(i, "D").Value < .Cells(i - 1, "D").Value Then

.Cells(i - 1, "D").Value = .Cells(i - 1, "D").Value & ",
" & _
.Cells(i, "D").Value
End If

If .Cells(i, "E").Value < .Cells(i - 1, "E").Value Then

.Cells(i - 1, "E").Value = .Cells(i - 1, "E").Value & ",
" & _
.Cells(i, "E").Value
End If

.Rows(i).Delete
End If
Next i

End With

End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"EE" wrote in message
ps.com...
Hi

Sorry that I could not even name this problem properly.

Please see tables below. The requirement will be quite obvious. Know
how to do this manually but not sure programmatically.

Thanks for the help.

Best
Prasad


Data Structure Before Macro

Name Place Animal Thing Number
Pers1 US Lion Pen One
Pers1 US Lion Pencil Two
Pers2 UK Bull Mouse Five


Data Structure After Macro
Name Place Animal Thing Number
Pers1 US Lion Pen, Pencil One, Two
Pers2 UK Bull Mouse Five



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
CONCATENATE multiple cells in a column Chris108 Excel Discussion (Misc queries) 4 December 15th 08 06:38 PM
Smart way to concatenate into B1 all cells below until new info in Column A Dennis Excel Discussion (Misc queries) 1 July 12th 06 01:06 PM
concatenate cells from a column and paste to a cell washdcjohn Excel Discussion (Misc queries) 3 November 15th 05 09:11 PM
Macro Help: Concatenate Populated Cells in Column A TJM Excel Discussion (Misc queries) 3 June 11th 05 11:25 AM
compare the first column and concatenate the second column smb2000user100 Excel Worksheet Functions 0 April 22nd 05 07:12 PM


All times are GMT +1. The time now is 11:25 AM.

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

About Us

"It's about Microsoft Excel"