×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Referencing VB userforms from Excel cell

Referencing VB userforms from Excel cell

Referencing VB userforms from Excel cell

(OP)
Hey guys,

I'm trying to write some simple code that will allow the userform that's opened by a single method to be altered depending on the value in an excel cell.
In the base case, cell A1 in Sheet1 has the value "Userform1". With in the method code I now need to transform this cell reference into a format that is compatible with the "Show" method.

Any help would be welcomed with open arms.

Craig
Replies continue below

Recommended for you

RE: Referencing VB userforms from Excel cell

The main thing is That Userform1 of VBA refer to "Object" whereas Userform1 of cell A1 refere to "string" value so these are not comparable.The following is the simple code which would work for you.Assume you have three userforms.

Sub Excelform()
    Select Case Cells(1, 1)
        Case "userform1"
            UserForm1.Show
        Case "userform2"
            UserForm2.Show
        Case "userform3"
            UserForm3.Show
        End Select
End Sub

RE: Referencing VB userforms from Excel cell

Hey cjg666!!!!
i hope this will solve ur problem
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Row = 1 And Target.Column = 1 Then
    Select Case Target
        Case "userform1"
            UserForm1.Show
        Case "userform2"
            UserForm2.Show
        Case "userform3"
            UserForm3.Show
        End Select
    Else
        UserForm1.Hide
        UserForm2.Hide
        UserForm3.Hide
    End If
End Sub

shakildor
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row = 1 And Target.Column = 1 Then
    Select Case Target
        Case "userform1"
            UserForm1.Show
        Case "userform2"
            UserForm2.Show
        Case "userform3"
            UserForm3.Show
        End Select
    Else
        UserForm1.Hide
        UserForm2.Hide
        UserForm3.Hide
    End If
End Sub

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close