You are on page 1of 2

Sub idelete()

Dim response As Integer


Dim ino As Long
Dim svalue As Integer
Dim lrow As Long
Dim lrow1 As Long
Dim lrow2 As Long
Dim crow As Integer
Dim crow1 As Integer
Dim ccount As Integer
Dim ccount1 As Integer
Dim irow As Integer
Dim irow1 As Integer
Dim irow2 As Integer
Dim ipull As Integer
Dim mcount As Integer
lrow = Sheets("DetailInvoice").Cells(Rows.Count, 1).End(xlUp).Row
lrow1 = Sheets("Invoices").Cells(Rows.Count, 1).End(xlUp).Row
lrow2 = Sheets("Ledger").Cells(Rows.Count, 1).End(xlUp).Row
On Error Resume Next
Application.DisplayAlerts = False
ino = Application.InputBox(Prompt:= _
"Please Enter Invoice.", _
Title:="DELETE INVOICE", Type:=1)
On Error GoTo 0
Application.DisplayAlerts = True
If ino = 0 Then
Exit Sub
Else
ccount = Application.WorksheetFunction.CountIf(Sheets("DetailInvoice").Range("A"
& 2 & ":A" & lrow), ino)
response = MsgBox("Are Your Sure (Yes/No)", vbYesNo + vbQuestion + vbDefaultButt
on2, "Confirm")
If response = vbYes Then
For crow = 2 To lrow
If Sheets("DetailInvoice").Cells(crow, 1).Text = ino Then
For irow = crow To crow
Sheets("DetailInvoice").Range("D" & irow & ":H" & irow).Value = ""
Next irow
End If
Next
For crow1 = 2 To lrow1
If Sheets("Invoices").Cells(crow1, 3).Text = ino Then
For irow1 = crow1 To crow1
Sheets("Invoices").Range("D" & irow1 & ":K" & irow1).Value = ""
Next irow1
End If
Next
For crow2 = 2 To lrow2
If Sheets("Ledger").Cells(crow2, 3).Text = ino Then
For irow2 = crow2 To crow2
Sheets("Ledger").Range("D" & irow2 & ":J" & irow2).Value = ""
Next irow2
End If
Next
MsgBox "Invoice Deleted Successfully"
Exit Sub
End If
End If
End Sub

You might also like