Results 1 to 3 of 3

Thread: Automatically open the userform when the cell value meet 7 digits

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2017
    Posts
    54

    Lightbulb Automatically open the userform when the cell value meet 7 digits

    Hello Everyone,

    Anyone Help me, i want open the userform automatically when the cell A2 having 7 digits number or else the the message
    should display like "Please enter 7 Digit".

    Thanks in advance.

  2. #2
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,936

    Re: Automatically open the userform when the cell value meet 7 digits

    Well, as far as I know, without subclassing, you're not going to be able to check the cell on every keystroke. However, you can check it when that cell loses focus. You could just put some code something like the following in the sheet that has your cell A2.

    Code:
    
    Option Explicit
    
    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Address = "$A$2" Then
            If Len(Target.Text) = 7 And Not Target.Text Like "*[!0-9]*" Then
                MsgBox "Your text is correct with 7 digits."
            Else
                MsgBox "Your text is not correct, and should have 7 digits."
            End If
        End If
    End Sub
    
    That's just an example. I'll let you design your own UserForms, and/or do whatever other work you wish to do.

    Enjoy,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2017
    Posts
    54

    Re: Automatically open the userform when the cell value meet 7 digits

    Thank you so much Elroy.
    Perfect it was worked what i want.

Posting Permissions

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



Click Here to Expand Forum to Full Width