Help with a macro for passwords

baldi

Board Regular
Joined
Sep 15, 2009
Messages
159
I have a workbook that has 3 sheets. On sheet 1 cell D7 is where I enter a password to get into sheet 2. sheet 3 is where I store the names and passwords. I need help writing a macro to check if the password entered in Cell D7 on sheet 1 matches the password in the chart on sheet 3. the password are in column D on sheet 3

Thanks for the Help in advance.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
I suspect you want more than you asked for. For example, you didn't tell us what you want to happen if there's a match or if there's no match. But, let's start with the sheet code below which you can try and then ask for modifications to include things you want but didn't ask for.

This is sheet code to be installed in Sheet1 following the steps below. The code will run automatically whenever a change is made to cell D7 on Sheet1.
To install sheet code:
1. Right-click the worksheet tab you want to apply it to and choose 'View Code'. This will open the VBE window.
2. Copy the code below from your browser window and paste it into the white space in the VBE window.
3. Close the VBE window and Save the workbook. If you are using Excel 2007 or a later version do a SaveAs and save it as a macro-enabled workbook (.xlsm file extension).
4. Make sure you have enabled macros whenever you open the file or the code will not run.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim n As Variant
Set Target = Target.Cells(1, 1)
If Not Intersect(Target, Range("D7")) Is Nothing Then
    If Target <> "" Then
        n = Application.Match(Target.Value, Sheets("Sheet3").Range("D:D"), 0)
        If Not IsError(n) Then
            MsgBox "There's a match on Sheet3, col D to Sheet1 cell D7"
        Else
            MsgBox "No match on sheet3, col D to sheet1 cell D7"
        End If
    End If
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top