Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Deleting specific rows


I have a spreadsheet that has approximately 200 store
numbers in Column A, starting in Row 2. In Column B,
there is either a "1" or a "0" for each store. I'd like
my macro to sort by Column B and then delete all of the
stores that have a "0". There will always be the same
number of stores, but each week their Col B value will
change. I know how to do the sort, but am not sure how to
identify and delete the "0" stores. Any help would be
appreciated. FYI, I'm using Excel 97 in Windows 2000
Professional. Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Deleting specific rows

Matt

why not use Data | Filter | AutoFilter, select the rows with 0 in column B
and then delete them. No macros required.

Regards

Trevor


"Matt" wrote in message
...

I have a spreadsheet that has approximately 200 store
numbers in Column A, starting in Row 2. In Column B,
there is either a "1" or a "0" for each store. I'd like
my macro to sort by Column B and then delete all of the
stores that have a "0". There will always be the same
number of stores, but each week their Col B value will
change. I know how to do the sort, but am not sure how to
identify and delete the "0" stores. Any help would be
appreciated. FYI, I'm using Excel 97 in Windows 2000
Professional. Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Deleting specific rows

Try this

It will look from row 2 till the last row with data in column B

Sub test()
Dim r As Long
With Worksheets("Sheet1")
For r = .Cells(Rows.Count, "B").End(xlUp).Row To 2 Step -1
If .Cells(r, "B").Value = 0 Then
.Rows(r).Delete
End If
Next
End With
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Matt" wrote in message ...

I have a spreadsheet that has approximately 200 store
numbers in Column A, starting in Row 2. In Column B,
there is either a "1" or a "0" for each store. I'd like
my macro to sort by Column B and then delete all of the
stores that have a "0". There will always be the same
number of stores, but each week their Col B value will
change. I know how to do the sort, but am not sure how to
identify and delete the "0" stores. Any help would be
appreciated. FYI, I'm using Excel 97 in Windows 2000
Professional. Thanks!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Deleting specific rows

Faster version

Sub test2()
Dim r As Long
Dim CalcMode As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

With Worksheets("Sheet1")
For r = .Cells(Rows.Count, "B").End(xlUp).Row To 2 Step -1
If .Cells(r, "B").Value = 0 Then
.Rows(r).Delete
End If
Next
End With

With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Matt" wrote in message ...

I have a spreadsheet that has approximately 200 store
numbers in Column A, starting in Row 2. In Column B,
there is either a "1" or a "0" for each store. I'd like
my macro to sort by Column B and then delete all of the
stores that have a "0". There will always be the same
number of stores, but each week their Col B value will
change. I know how to do the sort, but am not sure how to
identify and delete the "0" stores. Any help would be
appreciated. FYI, I'm using Excel 97 in Windows 2000
Professional. Thanks!



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
Deleting Rows w/ Specific Criteria MCSHMCH Excel Discussion (Misc queries) 2 September 28th 07 01:05 PM
Deleting rows with specific values whatzzup Excel Discussion (Misc queries) 1 July 6th 06 10:35 AM
Deleting row with specific value Jed Excel Discussion (Misc queries) 2 January 12th 06 01:59 PM
Deleting Specific Rows ScaffoldingDepot Excel Discussion (Misc queries) 2 May 4th 05 04:08 PM
Deleting rows with specific value from row 1 to 200 solo_razor[_23_] Excel Programming 1 November 4th 03 07:56 AM


All times are GMT +1. The time now is 06:34 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"