2
我正試圖在vba上創建一個登錄用戶窗體,但它會返回標題中所述的錯誤。所以這裏有一些背景。運行時錯誤:無法獲取WorksheetFunction類的Vlookup屬性
我有一張名爲「User_List」的工作表,其中有用戶名和他們的密碼。範圍從範圍B3開始到C1000。列B具有所有用戶名,而列C具有密碼。我想創建一個登錄用戶表單,以便在用戶輸入用戶名和密碼後,vba將搜索用戶列表並確定詳細信息是否正確。一旦確認,vba將引導用戶訪問另一個稱爲主頁的表格。以下是我的代碼。
Private Sub MLIB_Click()
Dim UserName As String
Dim PassWord As String
' MUN is the name of the textbox associated to the Username
' MPW is the name of the textbox associated to the Password
UserName = MUN.Value
PassWord = MPW.Value
If UserName = Application.WorksheetFunction.VLookup(UserName, Sheets("User_List").Range("B3:C1000"), 1, True) Then
If PassWord = Application.WorksheetFunction.VLookup(PassWord, Sheets("User_List").Range("B3:C1000"), 2, True) Then
Sheets("Home_Page").Activate
Unload Me
End If
End If
MsgBox "Sorry, Incorrect Login Details"
End Sub
一直試圖弄清楚這一點,但它需要很長時間!感謝任何幫助!
它給了我一個錯誤 - 運行時錯誤'438'(對象不支持這個屬性或方法),它突出顯示了下面的代碼。 If Not IsError(Application.Match(UserName,.Column(2),0))Then – Stu
我的歉意。這應該是'.Columns(2)',而不是'.Column(2)'。 – Jeeped
它完美的作品!謝謝!! – Stu