View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
Jarek Kujawa[_2_] Jarek Kujawa[_2_] is offline
external usenet poster
 
Posts: 896
Default Delete blank rows

Sub del()

pozycja = Application.WorksheetFunction.Match("Date", Columns(1))

If IsEmpty(Cells(pozycja - 1, 1)) And IsEmpty(Cells(pozycja - 2, 1))
Then
Range(pozycja - 2 & ":" & pozycja - 1).Rows.EntireRow.Delete
End If

End Sub



On 29 Kwi, 14:30, Marie Bayes
wrote:
Hi
Wonder if you can help. *I would like to put in some code to automatically
(on open) do the following:

Find the cell (in column A) with the word "Date" in, if the two rows above
this are blank, delete them.

Can anyone help? *I do have the following code already in and would like to
add the above to it:
Private Sub workbook_open()

Sheets("Sheet2").Select
* * Cells.Select
* * With Selection
* * * * .HorizontalAlignment = xlGeneral
* * * * .VerticalAlignment = xlBottom
* * * * .WrapText = False
* * * * .Orientation = 0
* * * * .AddIndent = False
* * * * .IndentLevel = 0
* * * * .ShrinkToFit = False
* * * * .ReadingOrder = xlContext
* * * * .MergeCells = False
* * End With
* * Cells.EntireColumn.AutoFit
End Sub

--
Marie Bayes