ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Combine similiar rows (https://www.excelbanter.com/excel-programming/391360-combine-similiar-rows.html)

Mike R.

Combine similiar rows
 
Hi!
I am pulling a report in that shows different activities that a person has
completed. When I pull the report, the first column has the activity (there
are two different types of activities possible) and the rest of the columns
are name, address, city, state. I would like to to run a macro in which it
will add two columns (for each activity) and put a 'X' in the column in which
the acitivty is completed. Also, when I run the report, a person could be
list twice if they have both activities, I would like for them to show once.
So, take the data from:

ACTIVITY NAME ADDRESS CITY STATE
RUN Mike Smith 1122 NE 4th Ave Orlando FL
RUN John Doe 234 S. 5th Str Orlando FL
WALK Mike Smith 1122 NE 4tf Ave Orlando FL
WALK Bob Jones 43 East Ave Orlando FL

and turn it in to:

RUN WALK NAME
X X Mike Smith 1122 NE 4th Ave Orlando FL
X John Doe 234 S. 5th Str Orlando FL
X Bob Jones 43 East Ave Orlando FL


I have tried too many ways with no avail. Any help would be great. Thanks,
Mike



PAR

Combine similiar rows
 
Here's the answer! Remember to give some feedback!

Sub SOLUTION()

Dim irows As Integer
Dim iloop

Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight

Cells(1, 2) = "RUN"
Cells(1, 3) = "WALK"


irows = ActiveSheet.UsedRange.Rows.Count

For iloop = 2 To irows
If Cells(iloop, 1) = "RUN" Then Cells(iloop, 2) = "X"
If Cells(iloop, 1) = "WALK" Then Cells(iloop, 3) = "X"
Next iloop

Columns("A:A").Select
Selection.Delete Shift:=xlToLeft


End Sub

"Mike R." wrote:

Hi!
I am pulling a report in that shows different activities that a person has
completed. When I pull the report, the first column has the activity (there
are two different types of activities possible) and the rest of the columns
are name, address, city, state. I would like to to run a macro in which it
will add two columns (for each activity) and put a 'X' in the column in which
the acitivty is completed. Also, when I run the report, a person could be
list twice if they have both activities, I would like for them to show once.
So, take the data from:

ACTIVITY NAME ADDRESS CITY STATE
RUN Mike Smith 1122 NE 4th Ave Orlando FL
RUN John Doe 234 S. 5th Str Orlando FL
WALK Mike Smith 1122 NE 4tf Ave Orlando FL
WALK Bob Jones 43 East Ave Orlando FL

and turn it in to:

RUN WALK NAME
X X Mike Smith 1122 NE 4th Ave Orlando FL
X John Doe 234 S. 5th Str Orlando FL
X Bob Jones 43 East Ave Orlando FL


I have tried too many ways with no avail. Any help would be great. Thanks,
Mike



Mike R.

Combine similiar rows
 
Hi - Thanks for the reply. This definitely gets me close. Now I would like
to combine 'like' people down to one row and have the appropriate 'X' next to
them. How do I combine them down to one row.
Thanks again,
Mike

"PAR" wrote:

Here's the answer! Remember to give some feedback!

Sub SOLUTION()

Dim irows As Integer
Dim iloop

Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight

Cells(1, 2) = "RUN"
Cells(1, 3) = "WALK"


irows = ActiveSheet.UsedRange.Rows.Count

For iloop = 2 To irows
If Cells(iloop, 1) = "RUN" Then Cells(iloop, 2) = "X"
If Cells(iloop, 1) = "WALK" Then Cells(iloop, 3) = "X"
Next iloop

Columns("A:A").Select
Selection.Delete Shift:=xlToLeft


End Sub

"Mike R." wrote:

Hi!
I am pulling a report in that shows different activities that a person has
completed. When I pull the report, the first column has the activity (there
are two different types of activities possible) and the rest of the columns
are name, address, city, state. I would like to to run a macro in which it
will add two columns (for each activity) and put a 'X' in the column in which
the acitivty is completed. Also, when I run the report, a person could be
list twice if they have both activities, I would like for them to show once.
So, take the data from:

ACTIVITY NAME ADDRESS CITY STATE
RUN Mike Smith 1122 NE 4th Ave Orlando FL
RUN John Doe 234 S. 5th Str Orlando FL
WALK Mike Smith 1122 NE 4tf Ave Orlando FL
WALK Bob Jones 43 East Ave Orlando FL

and turn it in to:

RUN WALK NAME
X X Mike Smith 1122 NE 4th Ave Orlando FL
X John Doe 234 S. 5th Str Orlando FL
X Bob Jones 43 East Ave Orlando FL


I have tried too many ways with no avail. Any help would be great. Thanks,
Mike




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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com