Deleting Rows Using Find

blaufer

I am trying to delete rows from the word Modifications to the row before Results. I was trying to use the Find command but I'm not having any luck. Here's one of the many variations I've tried:

Sub FindandDelete()
    Modifications = Range("A1:A1200").Find("Modifications", LookIn:=xlValues)
    Res = Cells.Find("Results", LookIn:=xlValues)
    Range("Modifications:Results").Delete
End Sub

Any ideas or suggestions?

whytheq

Try this:

Sub FindandDelete()

Dim Modifications As Excel.Range
Dim Res As Excel.Range

Set Modifications = Range("A1:A1200").Find(What:="Modifications", LookIn:=xlValues)
Set Res = Range("A1:A1200").Find(What:="Results", LookIn:=xlValues)

If Not (Modifications Is Nothing) And Not (Res Is Nothing) Then
    ActiveSheet.Range(Modifications, Res).EntireRow.Delete 'ClearContents '<<edit to delete rows rather than just clear their contents
End If

End Sub

This is slightly different using row numbers:

Sub FindandDeleteRows()

Dim Modifications As Integer
Dim Res As Integer

Dim lookinRange As Range
Set lookinRange = Excel.ThisWorkbook.ActiveSheet.Range("A1:A1200")

If Not (lookinRange.Find(What:="Modifications", LookIn:=xlValues) Is Nothing) Then
    Modifications = lookinRange.Find(What:="Modifications", LookIn:=xlValues).Row
End If
If Not (lookinRange.Find(What:="Results", LookIn:=xlValues) Is Nothing) Then
    Res = lookinRange.Find(What:="Results", LookIn:=xlValues).Row
End If

ActiveSheet.Rows(Modifications & ":" & Res).ClearContents

End Sub

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Deleting multiple rows in Excel using Apache POI

From Dev

Deleting multiple rows using checkboxes in Struts2

From Dev

Deleting a specific rows and columns from a data-set using Matlab

From Dev

Deleting multiple rows based on where clause using FluentMigrator

From Dev

Is deleting all rows in an R data frame using [-0,] officially supported?

From Dev

Deleting first two rows from a CSV using PIG or HIVE

From Dev

Deleting rows in google sheets using Google Apps Script

From Dev

MongoDB not deleting rows, no error using c# driver

From Dev

deleting lines between rows in a text file using awk or sed

From Dev

Deleting rows using not exists taking over 1 hour to finish

From Dev

Is deleting all rows in an R data frame using [-0,] officially supported?

From Dev

Deleting first two rows from a CSV using PIG or HIVE

From Dev

Deleting "string" containing last rows from CSV file using regex

From Dev

deleting multiple rows using check boxes with jquery in django?

From Dev

Deleting rows inside tableview while using sender.tag

From Dev

Calculate automatically in a table using jquery when adding or deleting rows

From Dev

Using ActiveRecord find_in_batches method for deleting large data

From Dev

Deleting Dataframe rows dynamically

From Dev

Conditional deleting rows in a matrix

From Dev

Deleting rows in R conditionally

From Dev

Deleting rows conditionally in r

From Dev

Tetris Deleting Rows Issue

From Dev

Deleting duplicate rows in sqlite?

From Dev

Deleting multiple rows in datagridview

From Dev

Bulk deleting rows with RemoveRange()

From Dev

Deleting Mysql rows with checkbox

From Dev

JTable search and deleting rows

From Dev

Deleting Duplicate Visible Rows

From Dev

Deleting an Array of rows and columns

Related Related

  1. 1

    Deleting multiple rows in Excel using Apache POI

  2. 2

    Deleting multiple rows using checkboxes in Struts2

  3. 3

    Deleting a specific rows and columns from a data-set using Matlab

  4. 4

    Deleting multiple rows based on where clause using FluentMigrator

  5. 5

    Is deleting all rows in an R data frame using [-0,] officially supported?

  6. 6

    Deleting first two rows from a CSV using PIG or HIVE

  7. 7

    Deleting rows in google sheets using Google Apps Script

  8. 8

    MongoDB not deleting rows, no error using c# driver

  9. 9

    deleting lines between rows in a text file using awk or sed

  10. 10

    Deleting rows using not exists taking over 1 hour to finish

  11. 11

    Is deleting all rows in an R data frame using [-0,] officially supported?

  12. 12

    Deleting first two rows from a CSV using PIG or HIVE

  13. 13

    Deleting "string" containing last rows from CSV file using regex

  14. 14

    deleting multiple rows using check boxes with jquery in django?

  15. 15

    Deleting rows inside tableview while using sender.tag

  16. 16

    Calculate automatically in a table using jquery when adding or deleting rows

  17. 17

    Using ActiveRecord find_in_batches method for deleting large data

  18. 18

    Deleting Dataframe rows dynamically

  19. 19

    Conditional deleting rows in a matrix

  20. 20

    Deleting rows in R conditionally

  21. 21

    Deleting rows conditionally in r

  22. 22

    Tetris Deleting Rows Issue

  23. 23

    Deleting duplicate rows in sqlite?

  24. 24

    Deleting multiple rows in datagridview

  25. 25

    Bulk deleting rows with RemoveRange()

  26. 26

    Deleting Mysql rows with checkbox

  27. 27

    JTable search and deleting rows

  28. 28

    Deleting Duplicate Visible Rows

  29. 29

    Deleting an Array of rows and columns

HotTag

Archive