+ Reply to Thread
Results 1 to 3 of 3

Userform option buttoms open relevent sheet

Hybrid View

  1. #1
    Registered User
    Join Date
    08-17-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    1

    Arrow Userform option buttoms open relevent sheet

    I have created a user form that looks like the following:

    1. Enter Name....

    2. Enter Telephone Number....

    3. Enter Address.....

    4. Select Department..... (from option buttons)

    - Primary
    - Secondary
    - Accounts
    - Overseas
    - Associations

    The department selection will determine which sheet to open (i.e. primiary sheet opened if primary selected) and enter the rest of the information into the next blank lines in the corresponding colums, i.e. Name in A, Telephone Number in B, Address in C. The userform should work when clicking a commandbutton.

    Is this possiable using the process/layout I have suggested and what would be the correct code to use?

    Thanks for taking the time to read this and any advise you can give

  2. #2
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Userform option buttoms open relevent sheet

    Hi,

    You can use an if statement to do what you need

    
    If OptionButton1 = True Then
        Sheets("Primary").Select
    ElseIf OptionButton2 = True Then
        Sheets("Secondary").Select
    ElseIf .OptionButton3 = True Then
        Sheets("Accounts").Select
    ElseIf OptionButton4 = True Then
        Sheets("Overseas").Select
    ElseIf OptionButton4 = True Then
        Sheets("Associations").Select
    Else
         msgBox("No department selected")
    End If

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Userform option buttoms open relevent sheet

    Hi,

    ... or if the option buttons are the last item to be actioned on the form just put Steffen's select code in the Option button click event and an Unload Me instruction.

    Regards
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1