PC Review


Reply
Thread Tools Rate Thread

Concatenate cells in one column of value in another column is same

 
 
EE
Guest
Posts: n/a
 
      18th Aug 2007
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 With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      18th Aug 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 With Quote
 
EE
Guest
Posts: n/a
 
      19th Aug 2007
On Aug 18, 3:53 am, "Bob Phillips" <bob....@somewhere.com> wrote:
> 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" <pras1...@gmail.com> wrote in message
>
> news:(E-Mail Removed)...
>
>
>
> > 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- Hide quoted text -

>
> - Show quoted text -


Many thanks.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
CONCATENATE multiple cells in a column Chris108 Microsoft Excel Misc 4 15th Dec 2008 06:38 PM
Smart way to concatenate into B1 all cells below until new info in Column A Dennis Microsoft Excel Misc 1 12th Jul 2006 01:06 PM
concatenate cells from a column and paste to a cell =?Utf-8?B?d2FzaGRjam9obg==?= Microsoft Excel Misc 3 15th Nov 2005 09:11 PM
Macro Help: Concatenate Populated Cells in Column A TJM Microsoft Excel Misc 3 11th Jun 2005 11:25 AM
Copying CONCATENATE formula to other cells in column =?Utf-8?B?VGlt?= Microsoft Excel Worksheet Functions 2 18th Jun 2004 03:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:23 AM.