Saturday, 18 August 2012

VB Program - To Delete the entire row if a specific cell value in a column is blank.

VB Program - To Delete the row if a specific cell value in a column is blank.
Program:

The below code will delete the entire row if Value in Column G is blank.

Sub delRow()

 For i = 1 To 100
    Cell1 = "G" + CStr(i)
    val1 = Range(Cell1).Value
    If val1 = "" Then
          Range(Cell1).Select
          Selection.EntireRow.Delete
    End If
 Next

End Sub

Note: Copy the code and run in Microsoft Visual Basic Editor.(Microsoft Excel)

No comments:

Post a Comment