[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VB Help

Posted on 2012-09-17
1
Medium Priority
?
360 Views
Last Modified: 2012-09-17
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
0
Comment
Question by:Kiwi-123
1 Comment
 
LVL 10

Accepted Solution

by:
SANTABABY earned 2000 total points
ID: 38407671
Add the following code in your sub:

Private Sub CommandButton3_Click()
Application.ScreenUpdating = False
Dim i As Long
Dim j As Long
Dim row As Range
   
   If InputBox("Please enter the password", "Enter Password") <> Worksheets("DataSheet").Range("B3") Then
        MsgBox "Incorrect Password."
        Exit Sub
    End If
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question