Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to Delete rows on a criteria

I have macro code to hide rows based on a certain critera but I don't
know how to adapt the code to delete the rows. Basically it checks a
column and for every row <0 it hides it. Problem is I want to delete
the row. How do i change the code below to delete?


BeginRow = 2
EndRow = 500
ChkCol = 13

For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value < 1 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
End If
Next RowCnt

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default Macro to Delete rows on a criteria

Try changing this line
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
to this:
Cells(RowCnt, ChkCol).EntireRow.Delete


--
-John
Please rate when your question is answered to help us and others know what
is helpful.


" wrote:

I have macro code to hide rows based on a certain critera but I don't
know how to adapt the code to delete the rows. Basically it checks a
column and for every row <0 it hides it. Problem is I want to delete
the row. How do i change the code below to delete?


BeginRow = 2
EndRow = 500
ChkCol = 13

For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value < 1 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
End If
Next RowCnt


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Macro to Delete rows on a criteria

For the OP

If you want to delete rows loop backwords
See this page for examples
http://www.rondebruin.nl/delete.htm


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"John Bundy" (remove) wrote in message ...
Try changing this line
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
to this:
Cells(RowCnt, ChkCol).EntireRow.Delete


--
-John
Please rate when your question is answered to help us and others know what
is helpful.


" wrote:

I have macro code to hide rows based on a certain critera but I don't
know how to adapt the code to delete the rows. Basically it checks a
column and for every row <0 it hides it. Problem is I want to delete
the row. How do i change the code below to delete?


BeginRow = 2
EndRow = 500
ChkCol = 13

For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value < 1 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
End If
Next RowCnt


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
Formula/Macro to delete rows that do not meet criteria from a list? S Davis Excel Worksheet Functions 2 July 12th 06 07:42 PM
Macro, delete rows that meet criteria Scott Wagner Excel Programming 4 December 23rd 05 12:06 AM
Delete rows with different criteria John Excel Programming 7 July 13th 05 05:38 PM
Cut and Paste macro based on criteria then delete empty rows samst Excel Programming 4 November 2nd 03 09:33 PM
Delete rows w/o criteria RickK[_2_] Excel Programming 2 October 31st 03 04:48 PM


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

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"