VBA Coding help please?

catcolors

New Member
Joined
Mar 14, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi,
My VB Code is not working.
What I am trying to do is this:
enter a Clock number(clocknumberbox) and password (passwordbox) on a form and if the password found on sheetTeam (C1) matches up to the CLOCKNUMBER SheetTeam (B1) clicking on the Log In command button will open another form named DataEntryForm
Private Sub cmdLogIn_Click()

‘data that is entered in the Entrance Form will search if clock number cell range b entered equals adjacent cell password looping as required

Dim Clock_Number As Integer

Dim Password As String

Dim Year As Integer

Clock_Number = SheetTeam.Range("B1").Value

Password = SheetTeam.Range("C1").Value

Dim c, rng As Range

Dim strclocknumber, strpassword As String

Dim shtTeam As Collection

Dim bFound As Boolean



Set shtEntry = ThisWorkbook.Sheets("Team") 'or wherever they are entering UN/PW

Set shtData = ThisWorkbook.Sheets("Team") 'or whatever sheet contains pws

Set rng = shtTeam("B:B")

bFound = False



strclocknumber = shtEntry.Range("N2") 'or wherever

strpassword = shtEntry.Range("O2") 'or wherever

For Each c In rng

If StrComp(c, strclocknumber, vbTextCompare) = 0 And _

StrComp(c.Offset(0, 1), strpassword, vbBinaryCompare) = 0 Then

DataEntryForm.Show

bFound = True

Exit For

End If

Next c



If bFound = False Then MsgBox "Incorrect User Name or Password"
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
You have one password and one clocknumber?
 
Upvote 0

Forum statistics

Threads
1,215,529
Messages
6,125,344
Members
449,219
Latest member
Smiqer

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