PC Review


Reply
Thread Tools Rate Thread

Convert Columns to Rows based upon a duplicate value

 
 
EJR
Guest
Posts: n/a
 
      31st Dec 2007
I have columnar data in the four headings below;

A B C
D
Loan Number / Taxpayer ID Number / Customer Name / SCR21

It is possible that there is information for two customer four each loan.
Is there a way for my to compare the values in the "Loan Number" column in
rows 3 and 2, and if it matches the cell above, copy the contents for columns
B, C & D and paste the to Columns E, F & G in row # 2?

Thanks for any help, EJR


 
Reply With Quote
 
 
 
 
Ken Hudson
Guest
Posts: n/a
 
      31st Dec 2007
Hi EJR,

Try the following code. Be sure to make a copy of your workbook first! After
moving the duplicate names, the code will delete the extra row. Post back if
you need to have this modified or if you need help setting up the macro.

Option Explicit
Dim Iloop As Double
Dim RowCount As Double
Sub MoveDupes()

'Turn off warnings, etc.
Application.ScreenUpdating = False
Application.DisplayAlerts = False

RowCount = Cells(Rows.Count, "A").End(xlUp).Row
For Iloop = RowCount To 2 Step -1
If Cells(Iloop, "A") = Cells(Iloop - 1, "A") Then
Cells(Iloop - 1, "E") = Cells(Iloop, "B")
Cells(Iloop - 1, "F") = Cells(Iloop, "C")
Cells(Iloop - 1, "G") = Cells(Iloop, "D")
Rows(Iloop).Delete
End If
Next Iloop

'Turn on warnings, etc.
Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub


--
Ken Hudson


"EJR" wrote:

> I have columnar data in the four headings below;
>
> A B C
> D
> Loan Number / Taxpayer ID Number / Customer Name / SCR21
>
> It is possible that there is information for two customer four each loan.
> Is there a way for my to compare the values in the "Loan Number" column in
> rows 3 and 2, and if it matches the cell above, copy the contents for columns
> B, C & D and paste the to Columns E, F & G in row # 2?
>
> Thanks for any help, EJR
>
>

 
Reply With Quote
 
Joel
Guest
Posts: n/a
 
      31st Dec 2007
The code below will delete the row with the same Loan Number

Sub combinrows()

RowCount = 1
Do While Range("A" & RowCount) <> ""
If Range("A" & RowCount) = _
Range("A" & (RowCount + 1)) Then

Range("B" & (RowCount + 1) & "" & _
(RowCount + 1)).Copy _
Destination:=Range("E" & RowCount)

Rows(RowCount + 1).Delete
Else
RowCount = RowCount + 1
End If
Loop

End Sub


if you don't want the row deleted then use this code

Sub combinrows()

RowCount = 1
Do While Range("A" & RowCount) <> ""
If Range("A" & RowCount) = _
Range("A" & (RowCount + 1)) Then

Range("B" & (RowCount + 1) & "" & _
(RowCount + 1)).Copy _
Destination:=Range("E" & RowCount)
End If

RowCount = RowCount + 1
Loop

End Sub

"EJR" wrote:

> I have columnar data in the four headings below;
>
> A B C
> D
> Loan Number / Taxpayer ID Number / Customer Name / SCR21
>
> It is possible that there is information for two customer four each loan.
> Is there a way for my to compare the values in the "Loan Number" column in
> rows 3 and 2, and if it matches the cell above, copy the contents for columns
> B, C & D and paste the to Columns E, F & G in row # 2?
>
> Thanks for any help, EJR
>
>

 
Reply With Quote
 
EJR
Guest
Posts: n/a
 
      31st Dec 2007
Hello Ken,
Thanks for your quick response. It worked like a charm.
Regards,
Evan R

"Ken Hudson" wrote:

> Hi EJR,
>
> Try the following code. Be sure to make a copy of your workbook first! After
> moving the duplicate names, the code will delete the extra row. Post back if
> you need to have this modified or if you need help setting up the macro.
>
> Option Explicit
> Dim Iloop As Double
> Dim RowCount As Double
> Sub MoveDupes()
>
> 'Turn off warnings, etc.
> Application.ScreenUpdating = False
> Application.DisplayAlerts = False
>
> RowCount = Cells(Rows.Count, "A").End(xlUp).Row
> For Iloop = RowCount To 2 Step -1
> If Cells(Iloop, "A") = Cells(Iloop - 1, "A") Then
> Cells(Iloop - 1, "E") = Cells(Iloop, "B")
> Cells(Iloop - 1, "F") = Cells(Iloop, "C")
> Cells(Iloop - 1, "G") = Cells(Iloop, "D")
> Rows(Iloop).Delete
> End If
> Next Iloop
>
> 'Turn on warnings, etc.
> Application.DisplayAlerts = True
> Application.ScreenUpdating = True
>
> End Sub
>
>
> --
> Ken Hudson
>
>
> "EJR" wrote:
>
> > I have columnar data in the four headings below;
> >
> > A B C
> > D
> > Loan Number / Taxpayer ID Number / Customer Name / SCR21
> >
> > It is possible that there is information for two customer four each loan.
> > Is there a way for my to compare the values in the "Loan Number" column in
> > rows 3 and 2, and if it matches the cell above, copy the contents for columns
> > B, C & D and paste the to Columns E, F & G in row # 2?
> >
> > Thanks for any help, EJR
> >
> >

 
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
Convert Columns to Rows and insert into another table based on valuesin columns Gurvinder Microsoft Access Form Coding 7 25th Nov 2008 10:03 PM
Convert Columns to Rows and insert into another table based on valuesin columns Gurvinder Microsoft Access Queries 0 24th Nov 2008 09:00 PM
How to convert duplicate rows into unique rows in a Table? KK Microsoft Access Queries 2 7th May 2008 02:40 PM
Convert columns to rows: create duplicate rows based on column val =?Utf-8?B?Q2FycmllUg==?= Microsoft Access 3 30th Aug 2006 07:07 PM
to convert columns to rows having mulit independent group columns =?Utf-8?B?UXVhY3k=?= Microsoft Excel Worksheet Functions 0 22nd Aug 2006 08:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:41 AM.