New Excel Forum

This forum has been moved to TeachExcel.com

Ask all future questions in the New Excel Forum.

ExcelKey

Macro to delete/add same row on multiple sheets (2)

Macros, VBA, Excel Automation, etc.

Re: Macro to delete/add same row on multiple sheets (2)

Postby mamunges » Thu Apr 21, 2016 9:54 am

Thank you NoSparks for your help and feedback . If you came to know how to deal with that please advice me in my email id - mamun.ges@gmail.com
  • 0

mamunges
Rookie
 
Posts: 10
Joined: Apr 18, 2016
Reputation: 0
Excel Version: 2007

Re: Macro to delete/add same row on multiple sheets (2)

Postby mamunges » Mon Aug 15, 2016 3:34 am

Hi,

I used the above code which doing great. But now I have a problem on the same aspect where add and remove micro work in unprotected sheets. In where of the code you made I need to change to do the job done.

Code: Select all
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


Thanks & Regards
  • 0

mamunges
Rookie
 
Posts: 10
Joined: Apr 18, 2016
Reputation: 0
Excel Version: 2007

Previous

Return to Macros and VBA Questions

Who is online

Users browsing this forum: Google [Bot] and 10 guests

cron