I am trying to write a macro for a button in Calc that will delete any row(s) from row 3 through 79 in a sheet that have the first cell in the row with a value of greater than 1. Here's what I've got so far but I'm running into trouble and I am not as familiar with writing Macros for OpenOffice Calc as I would like to be. I could use a fresh set of eyes. Thank you for any help.
Code: Select all
Sub DeleteRowswithSpecificValue()
Dim Range1 As object
Dim Cell
Dim LastRow As Long
Set Range1 = Range("A3")
LastRow = Range1.CurrentRegion.Rows.Count
LastRow = Range("A79").End(xlUp).Row
Set Range1 = Range(Range1, Range1.Offset(LastRow, 0))
For Each Cell In Range1
If Cell.Value = "2" Then
Debug.Print "' delete row from at address :: " & Cell.Address
Range(Cell.Address).EntireRow.Delete
End If
Next
End Sub