PC Review


Reply
Thread Tools Rate Thread

Delete rows if data changes in particular column

 
 
jscorsone
Guest
Posts: n/a
 
      22nd Feb 2008
Hi, I'm seeking assistance with a macro. I'm trying to delete subsequent
rows if data in a particular cell in Column B changes.

I need to create a macro because there are thousands of products and using
autofilter to sort and delete would take a while.

Any assistance would be greatly appreciate, thanks!
 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      22nd Feb 2008
More info

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"jscorsone" <(E-Mail Removed)> wrote in message
news:B1A3C229-760C-44DC-9DAF-(E-Mail Removed)...
> Hi, I'm seeking assistance with a macro. I'm trying to delete subsequent
> rows if data in a particular cell in Column B changes.
>
> I need to create a macro because there are thousands of products and using
> autofilter to sort and delete would take a while.
>
> Any assistance would be greatly appreciate, thanks!


 
Reply With Quote
 
jscorsone
Guest
Posts: n/a
 
      22nd Feb 2008
Sure, I didn't explain that very well.

I have 6 columns of data, thousands of rows of data.

Columns B, C, D, E, F will change. The column I'm concerned with is Column
B, Item Number. There are multiple rows of data with the same Item Number
(Column B.)

I'd like to delete all rows after the first row for a particular item name,
until Column B changes to a new number.


"Don Guillett" wrote:

> More info
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> (E-Mail Removed)
> "jscorsone" <(E-Mail Removed)> wrote in message
> news:B1A3C229-760C-44DC-9DAF-(E-Mail Removed)...
> > Hi, I'm seeking assistance with a macro. I'm trying to delete subsequent
> > rows if data in a particular cell in Column B changes.
> >
> > I need to create a macro because there are thousands of products and using
> > autofilter to sort and delete would take a while.
> >
> > Any assistance would be greatly appreciate, thanks!

>
>

 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      22nd Feb 2008
for
1
1
1
2
2
3
this will leave
1
2
3
Sub deletedups()
mc = "b"
For i = Cells(Rows.Count, mc).End(xlUp).Row To 2 Step -1
If Cells(i - 1, mc) = Cells(i, mc) Then Rows(i).Delete
Next
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"jscorsone" <(E-Mail Removed)> wrote in message
news:F1A79C9C-85E7-4823-A440-(E-Mail Removed)...
> Sure, I didn't explain that very well.
>
> I have 6 columns of data, thousands of rows of data.
>
> Columns B, C, D, E, F will change. The column I'm concerned with is
> Column
> B, Item Number. There are multiple rows of data with the same Item Number
> (Column B.)
>
> I'd like to delete all rows after the first row for a particular item
> name,
> until Column B changes to a new number.
>
>
> "Don Guillett" wrote:
>
>> More info
>>
>> --
>> Don Guillett
>> Microsoft MVP Excel
>> SalesAid Software
>> (E-Mail Removed)
>> "jscorsone" <(E-Mail Removed)> wrote in message
>> news:B1A3C229-760C-44DC-9DAF-(E-Mail Removed)...
>> > Hi, I'm seeking assistance with a macro. I'm trying to delete
>> > subsequent
>> > rows if data in a particular cell in Column B changes.
>> >
>> > I need to create a macro because there are thousands of products and
>> > using
>> > autofilter to sort and delete would take a while.
>> >
>> > Any assistance would be greatly appreciate, thanks!

>>
>>


 
Reply With Quote
 
jscorsone
Guest
Posts: n/a
 
      22nd Feb 2008
That's exactly what I needed. Thanks so much for your assistance!

"Don Guillett" wrote:

> for
> 1
> 1
> 1
> 2
> 2
> 3
> this will leave
> 1
> 2
> 3
> Sub deletedups()
> mc = "b"
> For i = Cells(Rows.Count, mc).End(xlUp).Row To 2 Step -1
> If Cells(i - 1, mc) = Cells(i, mc) Then Rows(i).Delete
> Next
> End Sub
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> (E-Mail Removed)
> "jscorsone" <(E-Mail Removed)> wrote in message
> news:F1A79C9C-85E7-4823-A440-(E-Mail Removed)...
> > Sure, I didn't explain that very well.
> >
> > I have 6 columns of data, thousands of rows of data.
> >
> > Columns B, C, D, E, F will change. The column I'm concerned with is
> > Column
> > B, Item Number. There are multiple rows of data with the same Item Number
> > (Column B.)
> >
> > I'd like to delete all rows after the first row for a particular item
> > name,
> > until Column B changes to a new number.
> >
> >
> > "Don Guillett" wrote:
> >
> >> More info
> >>
> >> --
> >> Don Guillett
> >> Microsoft MVP Excel
> >> SalesAid Software
> >> (E-Mail Removed)
> >> "jscorsone" <(E-Mail Removed)> wrote in message
> >> news:B1A3C229-760C-44DC-9DAF-(E-Mail Removed)...
> >> > Hi, I'm seeking assistance with a macro. I'm trying to delete
> >> > subsequent
> >> > rows if data in a particular cell in Column B changes.
> >> >
> >> > I need to create a macro because there are thousands of products and
> >> > using
> >> > autofilter to sort and delete would take a while.
> >> >
> >> > Any assistance would be greatly appreciate, 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
Delete Rows if any cell in Column H is blank but do not Delete Fir =?Utf-8?B?bWFuZmFyZWVk?= Microsoft Excel Programming 4 28th Sep 2007 05:20 PM
Delete Rows Where Value in Column V is Less than 2.5? =?Utf-8?B?U3RldmVD?= Microsoft Excel Programming 1 1st Feb 2006 09:18 PM
Delete rows with nothing in Column B marlea Microsoft Excel Programming 3 31st Jan 2006 03:39 PM
delete rows using macro when no data in column =?Utf-8?B?RGVyZWsgQ2hhbWJlcnM=?= Microsoft Excel Programming 1 21st Oct 2004 12:22 PM
Delete All Rows That Column A value is not in Column A of Sheet2 paxdak@yahoo.com Microsoft Excel Programming 2 3rd Sep 2004 09:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:12 PM.