Deleting and keeping rows in same Macro
Closed
Jess
-
Jul 26, 2010 at 08:03 AM
rizvisa1
rizvisa1
- Posts
- 4479
- Registration date
- Thursday January 28, 2010
- Status
- Contributor
- Last seen
- May 5, 2022
Related:
- Deleting and keeping rows in same Macro
- Delete or insert rows in a workbook ✓ - Forum - Excel
- Deleting and combining rows in excel with con ✓ - Forum - Excel
- VBA for deleting data in row but not formulas ✓ - Forum - Excel
- Coping formulas to next row using a macro ✓ - Forum - Excel
- Excel vba delete all table rows except first ✓ - Forum - Excel
1 reply
rizvisa1
Jul 26, 2010 at 08:18 AM
- Posts
- 4479
- Registration date
- Thursday January 28, 2010
- Status
- Contributor
- Last seen
- May 5, 2022
Jul 26, 2010 at 08:18 AM
Why you want to visit that cell again. If you know you have to delete the row, then delete it then. Some thing like this
Sub Delete() Dim rng As Range, cell As Range Dim strCellValue As String Set rng = Intersect(Range("H2:H1000"), ActiveSheet.UsedRange) For Each cell In rng strCellValue = (cell.Value) If InStr(strCellValue, "computer") = False Then If InStr(strCellValue, "laptop") = False Then On Error Resume Next cell.EntireRow.Delete On Error GoTo 0 End If End If Next cell End Sub
Jul 26, 2010 at 08:53 AM
Jul 26, 2010 at 09:26 AM
Jul 26, 2010 at 03:29 PM
Jul 26, 2010 at 07:42 PM
Jul 27, 2010 at 02:23 AM
In the uploaded document I have two macro's not finished yet. What I want is the following:
1#: Macro first keeps all the rows with "computer", "laptop", "latitude", etc.
2#: Macro looks at the kept rows again and deletes rows that include "geheugen", "module", "lamp", etc.
Is it possible to combine what I want in one macro? Thanks again.