D
Dileep Chandran
Hi Everybody,
I have a macro to cut and paste the entire row if the cell D is blank.
But I am facing an issue as its not stopping untill I press Esc button.
I need it to stop once it finish checking the last row which contain
data.
The macro is as follows:
Sub DeleteBlanks()
'Cut and Paste if Column D is blank
Dim myWord As String
Dim FoundCell As Range
Dim wks As Worksheet
Windows("Test.xls").Activate
Set wks = Worksheets("Sheet1")
myWord = ""
With wks.Range("D")
Do
Set FoundCell = .Cells.Find(what:=myWord, _
after:=.Cells(.Cells.Count), _
lookat:=xlWhole, MatchCase:=False)
If FoundCell Is Nothing Then
Exit Do
Else
FoundCell.EntireRow.Select
Selection.Cut
Sheets("Sheet2").Select
Cells(Rows.Count, 1).End(xlUp)(2).Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Selection.EntireRow.Delete
End If
Loop
End With
End Sub
Any help is appreciated
Thanks
-Dileep
I have a macro to cut and paste the entire row if the cell D is blank.
But I am facing an issue as its not stopping untill I press Esc button.
I need it to stop once it finish checking the last row which contain
data.
The macro is as follows:
Sub DeleteBlanks()
'Cut and Paste if Column D is blank
Dim myWord As String
Dim FoundCell As Range
Dim wks As Worksheet
Windows("Test.xls").Activate
Set wks = Worksheets("Sheet1")
myWord = ""
With wks.Range("D")
Do
Set FoundCell = .Cells.Find(what:=myWord, _
after:=.Cells(.Cells.Count), _
lookat:=xlWhole, MatchCase:=False)
If FoundCell Is Nothing Then
Exit Do
Else
FoundCell.EntireRow.Select
Selection.Cut
Sheets("Sheet2").Select
Cells(Rows.Count, 1).End(xlUp)(2).Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Selection.EntireRow.Delete
End If
Loop
End With
End Sub
Any help is appreciated
Thanks
-Dileep