Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Please help with some code for the following .....
I need to create a loop to scan down a column and if the contents of cell are say "D" then delete this row and go onto the next entry. Thank -- Message posted from http://www.ExcelForum.com |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
try something like the following: Sub delete_rows() Dim RowNdx As Long Dim LastRow As Long Application.ScreenUpdating = False LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row For RowNdx = LastRow To 1 Step -1 with Cells(RowNdx, "A") if .value = "value" then Rows(RowNdx).Delete End If end with Next RowNdx Application.ScreenUpdating = True End Sub -- Regards Frank Kabel Frankfurt, Germany Please help with some code for the following ..... I need to create a loop to scan down a column and if the contents of a cell are say "D" then delete this row and go onto the next entry. Thanks --- Message posted from http://www.ExcelForum.com/ |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Simon,
the following piece of code can be amended easily to handle this sort of thing. This version deletes empty rows in a range. To amend for your example (and assuming your values are in column A), change the If...Then line to If Cells(r,1).value = "D" Then Cheers, Pete Sub DeleteEmptyRows() Dim LastRow As Integer Dim r As Integer Application.ScreenUpdating = False LastRow = ActiveSheet.UsedRange.Row - 1 + _ ActiveSheet.UsedRange.Rows.Count For r = LastRow To 1 Step -1 If Application.WorksheetFunction.CountA(Rows(r)) = 0 Then Rows(r).Delete End If Next r Application.ScreenUpdating = True End Sub -----Original Message----- Please help with some code for the following ..... I need to create a loop to scan down a column and if the contents of a cell are say "D" then delete this row and go onto the next entry. Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro for deleting rows and serialising the remaing rows | Links and Linking in Excel | |||
Macro for deleting rows and serialising the remaing rows | Setting up and Configuration of Excel | |||
Macro for deleting rows and serialising the remaing rows | Excel Worksheet Functions | |||
Help!! I have problem deleting 2500 rows of filtered rows!!!! | Excel Discussion (Misc queries) | |||
deleting hidden rows so i can print only the rows showing?????? | Excel Worksheet Functions |