+ Reply to Thread
Results 1 to 6 of 6

Conditional logic based on name of worksheet

  1. #1
    Forum Contributor
    Join Date
    07-25-2008
    Location
    texas
    Posts
    178

    Conditional logic based on name of worksheet

    I need to put a macro in the toolbar which copies data from another worksheet. The trick is I have several worksheets and want the one macro to pull data from different columns based on which worksheet is active. So I need to test the name of the active worksheet in my logic.

    Ideas?
    Last edited by jartzh; 04-24-2009 at 05:19 PM.

  2. #2
    Registered User
    Join Date
    11-14-2008
    Location
    Tampa
    MS-Off Ver
    Professional Plus 2007
    Posts
    30

    Re: Conditional logic based on name of worksheet

    Here's an idea.

    set a variable to a number based on which sheet is active.
    And that variable should be associated to which column you want to pull data from.

    if sheet "Tampa" is active, set i=1
    if sheet "Detroit" is active, set i=2
    if sheet "Dallas" is active, set i=3

    then I would use the "offset" property in the range object.

    Please Login or Register  to view this content.
    Then if activesheet = "Tampa" you will pull data from column A
    If activesheet = "Detroit" you will pull data from column B
    If activesheet = "Dallas" you will pull data from column C

  3. #3
    Forum Contributor
    Join Date
    07-25-2008
    Location
    texas
    Posts
    178

    Re: Conditional logic based on name of worksheet

    Thats sounds perfect. Let me try it and get back to you.

  4. #4
    Forum Contributor
    Join Date
    07-25-2008
    Location
    texas
    Posts
    178

    Re: Conditional logic based on name of worksheet

    I have a problem.

    First the columns are consecutive so the i logic wont work. good idea though.

    But how to I test for worksheet "sheet1" to be active?

    Please Login or Register  to view this content.
    When I tried this , I get
    "OBJECT DOESNT SUPPORT THIS PROPERTY OR METHOD"
    Last edited by jartzh; 04-24-2009 at 04:13 PM.

  5. #5
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,607

    Re: Conditional logic based on name of worksheet

    Please Login or Register  to view this content.
    An expirement:
    Please Login or Register  to view this content.
    Last edited by protonLeah; 04-24-2009 at 04:31 PM.
    Ben Van Johnson

  6. #6
    Forum Contributor
    Join Date
    07-25-2008
    Location
    texas
    Posts
    178

    Re: Conditional logic based on name of worksheet

    Thanks a bunch.

    That did it.

    You guys are great!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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