Results 1 to 3 of 3

Thread: Open userform2 and register if the user is opening the workbook for the first time.... *SOLVED*

  1. #1
    Junior Member
    Join Date
    Mar 2019
    Posts
    7
    Rep Power
    0

    Open userform2 and register if the user is opening the workbook for the first time.... *SOLVED*

    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
    Attached Files Attached Files
    Last edited by DocAElstein; 04-02-2019 at 04:02 PM. Reason: SOLVED

  2. #2
    Junior Member
    Join Date
    Mar 2019
    Posts
    7
    Rep Power
    0
    I have been able to sort this one thank you

    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

  3. #3
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,389
    Rep Power
    10
    Thanks for telling us that you have your problem Solved
    Thanks for adding your solution.


    ( Please also remember to tell us if you post your questions in other Forums:
    Cross Post: https://www.excelforum.com/excel-pro...ml#post5089599
    http://www.excelfox.com/forum/showth...-Cross-Posters
    )
    Last edited by DocAElstein; 04-02-2019 at 04:19 PM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

Similar Threads

  1. Register / De-register OCX Files Using VBA
    By Rasm in forum Download Center
    Replies: 2
    Last Post: 12-12-2020, 10:55 PM
  2. Replies: 4
    Last Post: 04-10-2014, 10:58 PM
  3. Activate A Workbook After It Is Open
    By xander1981 in forum Excel Help
    Replies: 4
    Last Post: 04-02-2014, 04:14 PM
  4. Replies: 6
    Last Post: 08-25-2013, 12:35 PM
  5. Replies: 2
    Last Post: 01-29-2013, 02:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •