일부 지원 및 지원을 위해 스택 오버플로를 트롤링했으며 아래 코드를 찾았습니다. 이것을 사양으로 변경했습니다. 내가 VBA 코드를 원한다면 로그인을 클릭하면 "액세스 목록"이라는 시트를 검색하고 사용자가 시트에 있는지 확인합니다. 사용자가 발견되면 용지를 표시하십시오 (Pull Print, Push Print, USB, Thresholds 및 Site Contacts). 이 작업을 완료하면 "환영"페이지를 숨기고 싶습니다.Excel VBA 로그인하고 일정 수의 시트를 표시하려면
나는이 부분을 코딩 할 수 있었지만, 내가 고민하는 부분은 사용자가 사용자 이름 & 암호 필드를 공백으로 남겨두고 로그인 만하면된다는 것이다. 제가 보는 메시지가
개체
누군가가 나를 도와 주실 래요이 속성 또는 메서드를 지원하지 않습니다입니까?
Private Sub cmdLogin_Click()
Dim RowNo As Long
Dim Id As String, pw As String
Dim ws As Worksheet
Dim aCell As Range
On Error GoTo ErrorHandler
If Len(Trim(txtlogin)) = 0 Then
txtlogin.SetFocus
MsgBox "Username cannot be empty"
Exit Sub
End If
If Len(Trim(txtpassword)) = 0 Then
txtpassword.SetFocus
MsgBox "Password cannot be empty"
Exit Sub
End If
Application.ScreenUpdating = False
Set ws = Worksheets("Access List")
Id = LCase(Me.txtlogin)
Set aCell = ws.Columns(1).Find(What:=Id, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
'~~> If match found
If Not aCell Is Nothing Then
RowNo = aCell.Row
If Me.txtpassword = aCell.Offset(, 1) Then
Else
Sheets("Home").Visible = xlSheetHidden
Sheets("Pull Print").Visible = True
Sheets("Push Print").Visible = True
Sheets("USB").Visible = True
Sheets("Thresholds").Visible = True
Sheets("Site Contacts").Visible = True
Sheets("Access List").Visible = xlSheetHidden
MsgBox "Unable to match UserID or PasswordID, Please try again", vbOKOnly
End If
Else '<~~ If not found
MsgBox "Unable to match UserID or PasswordID, Please try again", vbOKOnly
End If
CleanExit:
Set ws = Nothing
Application.ScreenUpdating = True
Exit Sub
ErrorHandler:
MsgBox Err.Description
Resume CleanExit
End Sub
나는 이것을 반영하기 위해 코드를 변경했으며 로그인을 클릭해도 여전히 페이지 숨기기가되지 않습니다. –