PC Review


Reply
Thread Tools Rate Thread

Combine like rows

 
 
=?Utf-8?B?TWlrZSBSLg==?=
Guest
Posts: n/a
 
      16th Jun 2007
Hi -
In my data, there are 5 columns, CAR, TRUCK, NAME, CITY, STATE. The first
two columns will have a X in it if the person has a CAR or TRUCK. With the
data I am pulling from, if the same person has both a Car and Truck, they
will show up twice in seperate rows. I would like to find when a person has
both and combine it to one row (with a X in each CAR and TRUCK). So from:

CAR TRUCK NAME CITY STATE
X Mike Orlando FL
X Mike Orlando FL

To:

CAR TRUCK NAME CITY STATE
X X Mike Orlando FL

Help please...I am stuck.
Thanks,
Mike
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      16th Jun 2007
Sub combinerows()

Const CarCol = "A"
Const TruckCol = "B"
Const NameCol = "C"
Const CityCol = "D"
Const StateCol = "E"

RowCount = 2
Do While Not IsEmpty(Cells(RowCount + 1, NameCol))
If Cells(RowCount, NameCol) = _
Cells(RowCount + 1, NameCol) And _
Cells(RowCount, CityCol) = _
Cells(RowCount + 1, CityCol) And _
Cells(RowCount, StateCol) = _
Cells(RowCount + 1, StateCol) Then

If IsEmpty(Cells(RowCount, CarCol)) Then
Cells(RowCount, CarCol) = _
Cells(RowCount + 1, CarCol)
End If
If IsEmpty(Cells(RowCount, TruckCol)) Then
Cells(RowCount, TruckCol) = _
Cells(RowCount + 1, TruckCol)
End If

Cells(RowCount + 1, "A").EntireRow.Delete
End If

RowCount = RowCount + 1
Loop

End Sub


"Mike R." wrote:

> Hi -
> In my data, there are 5 columns, CAR, TRUCK, NAME, CITY, STATE. The first
> two columns will have a X in it if the person has a CAR or TRUCK. With the
> data I am pulling from, if the same person has both a Car and Truck, they
> will show up twice in seperate rows. I would like to find when a person has
> both and combine it to one row (with a X in each CAR and TRUCK). So from:
>
> CAR TRUCK NAME CITY STATE
> X Mike Orlando FL
> X Mike Orlando FL
>
> To:
>
> CAR TRUCK NAME CITY STATE
> X X Mike Orlando FL
>
> Help please...I am stuck.
> Thanks,
> Mike

 
Reply With Quote
 
=?Utf-8?B?TWlrZSBSLg==?=
Guest
Posts: n/a
 
      16th Jun 2007
Hi - thanks for the reply. For some reason, this does not seem to work.
More help please. I really appreciate it.
Mike

"Joel" wrote:

> Sub combinerows()
>
> Const CarCol = "A"
> Const TruckCol = "B"
> Const NameCol = "C"
> Const CityCol = "D"
> Const StateCol = "E"
>
> RowCount = 2
> Do While Not IsEmpty(Cells(RowCount + 1, NameCol))
> If Cells(RowCount, NameCol) = _
> Cells(RowCount + 1, NameCol) And _
> Cells(RowCount, CityCol) = _
> Cells(RowCount + 1, CityCol) And _
> Cells(RowCount, StateCol) = _
> Cells(RowCount + 1, StateCol) Then
>
> If IsEmpty(Cells(RowCount, CarCol)) Then
> Cells(RowCount, CarCol) = _
> Cells(RowCount + 1, CarCol)
> End If
> If IsEmpty(Cells(RowCount, TruckCol)) Then
> Cells(RowCount, TruckCol) = _
> Cells(RowCount + 1, TruckCol)
> End If
>
> Cells(RowCount + 1, "A").EntireRow.Delete
> End If
>
> RowCount = RowCount + 1
> Loop
>
> End Sub
>
>
> "Mike R." wrote:
>
> > Hi -
> > In my data, there are 5 columns, CAR, TRUCK, NAME, CITY, STATE. The first
> > two columns will have a X in it if the person has a CAR or TRUCK. With the
> > data I am pulling from, if the same person has both a Car and Truck, they
> > will show up twice in seperate rows. I would like to find when a person has
> > both and combine it to one row (with a X in each CAR and TRUCK). So from:
> >
> > CAR TRUCK NAME CITY STATE
> > X Mike Orlando FL
> > X Mike Orlando FL
> >
> > To:
> >
> > CAR TRUCK NAME CITY STATE
> > X X Mike Orlando FL
> >
> > Help please...I am stuck.
> > Thanks,
> > Mike

 
Reply With Quote
 
=?Utf-8?B?TWlrZSBSLg==?=
Guest
Posts: n/a
 
      16th Jun 2007
Hi - I have figured it out. The code works when I sort by name. Thanks!
Mike

"Mike R." wrote:

> Hi - thanks for the reply. For some reason, this does not seem to work.
> More help please. I really appreciate it.
> Mike
>
> "Joel" wrote:
>
> > Sub combinerows()
> >
> > Const CarCol = "A"
> > Const TruckCol = "B"
> > Const NameCol = "C"
> > Const CityCol = "D"
> > Const StateCol = "E"
> >
> > RowCount = 2
> > Do While Not IsEmpty(Cells(RowCount + 1, NameCol))
> > If Cells(RowCount, NameCol) = _
> > Cells(RowCount + 1, NameCol) And _
> > Cells(RowCount, CityCol) = _
> > Cells(RowCount + 1, CityCol) And _
> > Cells(RowCount, StateCol) = _
> > Cells(RowCount + 1, StateCol) Then
> >
> > If IsEmpty(Cells(RowCount, CarCol)) Then
> > Cells(RowCount, CarCol) = _
> > Cells(RowCount + 1, CarCol)
> > End If
> > If IsEmpty(Cells(RowCount, TruckCol)) Then
> > Cells(RowCount, TruckCol) = _
> > Cells(RowCount + 1, TruckCol)
> > End If
> >
> > Cells(RowCount + 1, "A").EntireRow.Delete
> > End If
> >
> > RowCount = RowCount + 1
> > Loop
> >
> > End Sub
> >
> >
> > "Mike R." wrote:
> >
> > > Hi -
> > > In my data, there are 5 columns, CAR, TRUCK, NAME, CITY, STATE. The first
> > > two columns will have a X in it if the person has a CAR or TRUCK. With the
> > > data I am pulling from, if the same person has both a Car and Truck, they
> > > will show up twice in seperate rows. I would like to find when a person has
> > > both and combine it to one row (with a X in each CAR and TRUCK). So from:
> > >
> > > CAR TRUCK NAME CITY STATE
> > > X Mike Orlando FL
> > > X Mike Orlando FL
> > >
> > > To:
> > >
> > > CAR TRUCK NAME CITY STATE
> > > X X Mike Orlando FL
> > >
> > > Help please...I am stuck.
> > > Thanks,
> > > Mike

 
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
Combine rows and Qty jml2008 Microsoft Excel Misc 1 12th Apr 2010 07:24 PM
How do I combine worksheets w/o enough rows to combine? Amanda W. Microsoft Excel Worksheet Functions 3 9th Jun 2009 07:26 AM
combine 2 rows into 1 Dave Microsoft ASP .NET 7 18th Feb 2008 05:16 PM
Combine rows beanmonger Microsoft Excel Misc 3 11th Oct 2005 10:34 AM
how to combine the multiple rows into one rows? =?Utf-8?B?UnVzeQ==?= Microsoft Excel Worksheet Functions 0 19th Jul 2005 02:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:27 PM.