Link to home
Start Free TrialLog in
Avatar of Kiwi-123
Kiwi-123

asked on

VB Help

Please can you help me alter the attached file. I want to change the command button code so that it requires a password. The password would be held in sheet4 "datasheet" B3

Private Sub CommandButton3_Click()
Application.ScreenUpdating = False
Dim i As Long
Dim j As Long
Dim row As Range
   
    j = Sheets("Archive").Range("B" & ActiveSheet.Rows.Count).End(xlUp).row + 1
    For i = 9 To ActiveSheet.Range("B" & ActiveSheet.Rows.Count).End(xlUp).row
        Set row = ActiveSheet.Range("A" & i)
        If row.Cells(1, 14).Value <> "" Then
        Sheets("Archive").Unprotect Sheets("DataSheet").Range("C4").Value
            Sheets("Archive").Range("B" & j & ":S" & j).Value = ActiveSheet.Range("B" & i & ":S" & i).Value
            j = j + 1
            Sheets("Archive").Protect Sheets("DataSheet").Range("C4").Value
        End If
    Next i
    ' Delete the archived rows
    For i = ActiveSheet.Range("B" & ActiveSheet.Rows.Count).End(xlUp).row To 9 Step -1
        Set row = ActiveSheet.Range("A" & i)
        If row.Cells(1, 14).Value <> "" Then
        Sheets("Low Volume").Unprotect Sheets("DataSheet").Range("C5").Value
            row.Rows(1).EntireRow.Delete
        Sheets("Low Volume").Protect Sheets("DataSheet").Range("C5").Value
        Application.ScreenUpdating = True
        End If
    Next i
End Sub


Thanks for your help
help-12-09-2012.xls
ASKER CERTIFIED SOLUTION
Avatar of SANTABABY
SANTABABY
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial