This forum has been moved to TeachExcel.com
Ask all future questions in the New Excel Forum.
ExcelKey
Option Explicit
Option Base 0
Const PW As String = "0"
Public Enum Act
ActAdd = 1
ActDel
End Enum
Public Sub AddOrDeleteRow(ByVal ActWhat As Long)
Dim Ws() As Variant
Dim R As Long
Dim i As Integer
Ws = Array("MAIN SHEET", "SALARY & OTHERS", "LUNCH SUBSIDITY", "FASTIVAL")
With Selection
If .Rows.Count > 1 Then Exit Sub
R = .Row
End With
For i = LBound(Ws) To UBound(Ws)
With Worksheets(Ws(i))
.Unprotect PW
If ActWhat = ActDel Then
.Rows(R).Delete
Else
.Rows(R).Insert
End If
.Protect Password:=PW, Userinterfaceonly:=False
End With
Next i
End Sub
Return to Macros and VBA Questions
Users browsing this forum: No registered users and 97 guests