Consulting

Results 1 to 3 of 3

Thread: Solved: Activate certain sheet based on cell content

  1. #1

    Solved: Activate certain sheet based on cell content

    I'm trying to activate an existing worksheet via code based on the text content of a cell.

    I've named the worksheets/tabs matching a list in an indexed cell attached to a drop-down-list-box (named "RecipeCatagory").

    Indexed in that cell are: "Pork, Beef, Chicken, Seafood, Side_Dish, Dessert"

    A silly example of what I'm trying to accomplish via code that obviously wouldn't work:

    [vba]
    Dim RecipeCatagory As Long

    RecipeCatagory = Range("Catagory").Text

    Windows("RecipeList.xlsm").Activate
    Sheets(RecipeCatagory).Activate
    [/vba]

    I'm stumped.

  2. #2
    VBAX Mentor
    Joined
    Feb 2009
    Posts
    493
    Location
    [vba]sub test
    Dim RecipeCatagory As String
    RecipeCatagory = Range("Catagory").value
    thisworkbook.Sheets(RecipeCatagory).Activate
    end sub [/vba]

    btw it is spelled category

  3. #3
    Oh man. You fixed it but for a different reason.

    My script worked...it was the typo that kept tripping it it up. I had named the sheet and cell correctly. I did change the .text to .value through.

    Ironically I'm usually a stickler when it comes to tipos.

Posting Permissions

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