Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Conditional Row Delete

Review many postings on conditional row delete but still need help. I
want to delete all rows where there are fewer than 5 companies within
industry. The median within that industry is not very useful if there
are less than 5, or some other number, of companies.

Company SIC Code Sales

If frequency of SIC code is less than 5, then delete the row.

Please help.

  #3   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Conditional Row Delete

One thing you can try:

First, back up your work.

Then turn on Autofilter (Data/Filter/Autofilter). Click the drop arrow on
SIC Code column. Select custom from the list and "is less than" 5. Select
the results of the filter and Edit/Delete. Then turn off the autofilter.


" wrote:

Review many postings on conditional row delete but still need help. I
want to delete all rows where there are fewer than 5 companies within
industry. The median within that industry is not very useful if there
are less than 5, or some other number, of companies.

Company SIC Code Sales

If frequency of SIC code is less than 5, then delete the row.

Please help.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Conditional Row Delete

JMB, this is a PERFECT example of how I always go about things the wrong
way. I was getting ready to reply to this (every decade or so I try to give
something back) with all kinds of ways to check for values less than 5
(assuming that's the question, it might be checking for less than 5
instances of the SIC number in a column) and delete using VBA, and then I
read your post. Autofilter didn't even OCCUR to me.

I have to laugh at myself sometimes.

Good answer, JMB.


"JMB" wrote in message
...
One thing you can try:

First, back up your work.

Then turn on Autofilter (Data/Filter/Autofilter). Click the drop arrow on
SIC Code column. Select custom from the list and "is less than" 5.
Select
the results of the filter and Edit/Delete. Then turn off the autofilter.


" wrote:

Review many postings on conditional row delete but still need help. I
want to delete all rows where there are fewer than 5 companies within
industry. The median within that industry is not very useful if there
are less than 5, or some other number, of companies.

Company SIC Code Sales

If frequency of SIC code is less than 5, then delete the row.

Please help.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Conditional Row Delete

On Feb 3, 4:47 pm, wrote:
Review many postings on conditional row delete but still need help. I
want to delete all rows where there are fewer than 5 companies within
industry. The median within that industry is not very useful if there
are less than 5, or some other number, of companies.

Company SIC Code Sales

If frequency of SIC code is less than 5, then delete the row.

Please help.


It's the "freqency" part that's important. I don't want an industry
which is only represented by five or fewer companies. The SIC code
will change. For example if there are five companies within the SIC
Code 1, then I want to keep them and calculate medians, otherwise
delete the company.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Conditional Row Delete

assume SIC code is in column B

Assuming one company per row:

Sub ABC()
Dim lastrow as long
lastrow = Cells(rows.count,2).End(xlup).row
for i = lastrow to 2 step -1
if application.countif(B:B,cells(i,2) < 5 then
rows(i).Delete
end if
Next i
End Sub



--
Regards,
Tom Ogilvy


wrote in message
oups.com...
On Feb 3, 4:47 pm, wrote:
Review many postings on conditional row delete but still need help. I
want to delete all rows where there are fewer than 5 companies within
industry. The median within that industry is not very useful if there
are less than 5, or some other number, of companies.

Company SIC Code Sales

If frequency of SIC code is less than 5, then delete the row.

Please help.


It's the "freqency" part that's important. I don't want an industry
which is only represented by five or fewer companies. The SIC code
will change. For example if there are five companies within the SIC
Code 1, then I want to keep them and calculate medians, otherwise
delete the company.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Conditional Row Delete

Had typo(s) in the countif line:

Sub ABC()
Dim lastrow as long
Dim i as Long
lastrow = Cells(rows.count,2).End(xlup).row
for i = lastrow to 2 step -1
if application.countif(Range("B:B"),cells(i,2)) < 5 then
rows(i).Delete
end if
Next i
End Sub

--
Regards,
Tom Ogilvy



"Tom Ogilvy" wrote in message
...
assume SIC code is in column B

Assuming one company per row:

Sub ABC()
Dim lastrow as long
lastrow = Cells(rows.count,2).End(xlup).row
for i = lastrow to 2 step -1
if application.countif(B:B,cells(i,2) < 5 then
rows(i).Delete
end if
Next i
End Sub



--
Regards,
Tom Ogilvy


wrote in message
oups.com...
On Feb 3, 4:47 pm, wrote:
Review many postings on conditional row delete but still need help. I
want to delete all rows where there are fewer than 5 companies within
industry. The median within that industry is not very useful if there
are less than 5, or some other number, of companies.

Company SIC Code Sales

If frequency of SIC code is less than 5, then delete the row.

Please help.


It's the "freqency" part that's important. I don't want an industry
which is only represented by five or fewer companies. The SIC code
will change. For example if there are five companies within the SIC
Code 1, then I want to keep them and calculate medians, otherwise
delete the company.





  #8   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Conditional Row Delete

Correction - almost a good answer. Looks like Don had it right the first
time - more details were needed. But the OP could have set up a helper
column using Countif and filter on the helper column.


"CompleteNewb" wrote:

JMB, this is a PERFECT example of how I always go about things the wrong
way. I was getting ready to reply to this (every decade or so I try to give
something back) with all kinds of ways to check for values less than 5
(assuming that's the question, it might be checking for less than 5
instances of the SIC number in a column) and delete using VBA, and then I
read your post. Autofilter didn't even OCCUR to me.

I have to laugh at myself sometimes.

Good answer, JMB.


"JMB" wrote in message
...
One thing you can try:

First, back up your work.

Then turn on Autofilter (Data/Filter/Autofilter). Click the drop arrow on
SIC Code column. Select custom from the list and "is less than" 5.
Select
the results of the filter and Edit/Delete. Then turn off the autofilter.


" wrote:

Review many postings on conditional row delete but still need help. I
want to delete all rows where there are fewer than 5 companies within
industry. The median within that industry is not very useful if there
are less than 5, or some other number, of companies.

Company SIC Code Sales

If frequency of SIC code is less than 5, then delete the row.

Please help.





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional delete tom[_2_] Excel Discussion (Misc queries) 2 October 15th 09 10:44 PM
Conditional Delete [email protected] New Users to Excel 3 May 25th 07 03:25 AM
Conditional Row Delete Sparky[_2_] Excel Programming 2 September 17th 04 03:58 AM
CONDITIONAL DELETE SH Excel Programming 2 August 17th 04 12:01 AM
Conditional row delete Penny[_3_] Excel Programming 1 July 30th 03 06:25 PM


All times are GMT +1. The time now is 08:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"