+ Reply to Thread
Results 1 to 8 of 8

Code to Activate a sheet 1 [IF] Userform box is "X" if not Activate Sheet 2

  1. #1
    Registered User
    Join Date
    01-23-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    81

    Code to Activate a sheet 1 [IF] Userform box is "X" if not Activate Sheet 2

    Hi, I need some help here, I'm having a rough time with this one. I have a userform to input data into a table and I'm trying to make it run on a certain sheet (Sheet 1) if the userform text box value is "X" and a different sheet (Sheet 2) if its "Y" I have two different scripts of data to input depending on what the text box says. Thanks for the help.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Code to Activate a sheet 1 [IF] Userform box is "X" if not Activate Sheet 2

    UNTESTED CODE
    Assumes you are using a command button to start your macro.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    01-23-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    81

    Re: Code to Activate a sheet 1 [IF] Userform box is "X" if not Activate Sheet 2

    Just tried that in the code and it is not working, it doesn't give me any compilation errors but the code just does not do anything. I can post my code if it will help.

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Code to Activate a sheet 1 [IF] Userform box is "X" if not Activate Sheet 2

    Post Your Spreadsheet.

    The code above is not practical it just shows you the method to use.

  5. #5
    Registered User
    Join Date
    01-23-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    81

    Re: Code to Activate a sheet 1 [IF] Userform box is "X" if not Activate Sheet 2

    Understood. I just tried to implement the syntax you used to no avail. Below is a test spreadsheet.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Code to Activate a sheet 1 [IF] Userform box is "X" if not Activate Sheet 2

    1. Where is the code that I am looking for.

    2. I modified some of your code, why dosn't it work in your userform?

    Please Login or Register  to view this content.
    3. After a while I found it a pain to name my textboxes and checkboxes.
    If you leave their names alone then you can use loops to fill and save them.

    http://www.excelforum.com/excel-prog...ml#post3566034
    Last edited by mehmetcik; 01-30-2014 at 05:10 PM.

  7. #7
    Registered User
    Join Date
    01-23-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    81

    Re: Code to Activate a sheet 1 [IF] Userform box is "X" if not Activate Sheet 2

    1. The code in question is the submitform_click() code to fill the user form information into the excel sheet. It's the code attached to the user form submit button.

    2. That is good to know for the future. All the companies and divisions are named different I just desensitised it to post it without getting in trouble. The issue I'm having with the code is that when I submit the form the code seems to do nothing but also does not provide me with an error code.

    3. That is a good tip thanks.

  8. #8
    Registered User
    Join Date
    01-23-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    81

    Re: Code to Activate a sheet 1 [IF] Userform box is "X" if not Activate Sheet 2

    Hey Mehmetcik, wondering if you were able to get that to work? I still have not been able to figure out how to correctly format the of statement to activate the sheet based on a input control criteria.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 01-02-2014, 04:05 PM
  2. get "run time error 1004" when i try to activate macro on protected sheet why?
    By ASAFSWIS in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-19-2013, 11:37 AM
  3. [SOLVED] Activate "sorting" feature when worksheets are setup to "password protect" itself
    By nenadmail in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-26-2012, 09:04 PM
  4. Prevent code in "Sheet Activate" from running when sheet made visible from other macr
    By Simon Lloyd in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-21-2006, 04:15 AM
  5. [SOLVED] How to activate "New" tab in Dataform through VB Code
    By shajueasow in forum Excel General
    Replies: 2
    Last Post: 05-01-2005, 09:06 AM

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