Open userform2 and register if the user is opening the workbook for the first time... (1 Viewer)

raghuprabhu

Registered User.
Local time
Today, 09:32
Joined
Mar 24, 2008
Messages
154
I have a work book with two worksheets. One is to input data “Sheet1” and other one to hold the details of the users “Sheet2”. It has two forms “Userform1” and ”Userform2”

When the user opens the workbook,

If the user is not in the “Sheet2” then
Open Userform2, input the users details
Save and close and open Userform1
Else
open Userform1
End if


Ps the form "Userform1" opens automatically. Click "Close" and then go from there..

I am trying to sort this and was finding it a bit tricky.

Thank you

Kind regards

Raghu
 

Attachments

  • testing.zip
    21.6 KB · Views: 106

Gasman

Enthusiastic Amateur
Local time
Today, 16:32
Joined
Sep 21, 2011
Messages
14,044
Last edited:

raghuprabhu

Registered User.
Local time
Today, 09:32
Joined
Mar 24, 2008
Messages
154
I have been been able to sort this out

Code:
Private Sub Workbook_Open()
On Error GoTo myErrorHandler:

Dim User_Name As String
Dim myRange As Range
Dim yesNo As Variant

Set myRange = Sheet2.Range("A:A")

User_Name = Environ("username")

yesNo = Application.WorksheetFunction.VLookup(User_Name, myRange, 1, False)

myErrorHandler:
    If Err.Number = 1004 Then
        UserForm2.Show
    Else
        UserForm1.Show
    End If
End Sub

Thank you
 

Users who are viewing this thread

Top Bottom