PDA

View Full Version : Solved: Activate certain sheet based on cell content



DanOfEarth
03-28-2011, 08:11 AM
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:


Dim RecipeCatagory As Long

RecipeCatagory = Range("Catagory").Text

Windows("RecipeList.xlsm").Activate
Sheets(RecipeCatagory).Activate


I'm stumped.

BrianMH
03-28-2011, 08:50 AM
sub test
Dim RecipeCatagory As String
RecipeCatagory = Range("Catagory").value
thisworkbook.Sheets(RecipeCatagory).Activate
end sub

btw it is spelled category

DanOfEarth
03-28-2011, 09:20 AM
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.:wot