Tabs not showing

Solved/Closed
Mary - Jun 7, 2010 at 08:13 PM
 Mary - Jun 8, 2010 at 07:46 PM
Hello,

A few days ago somebody very kind gave a hand with this, but I am having a problem:
every time I use combo box it should be showing tabs "May In" and "May Out" if I choose "May In" on the Combo box, and "June In" and "June Out" if I choose June In and so on, but actually is only showing June In, August In, September In.

Problems:
1. May In is not showing, why?
2. when I choose one tab like May In it should be showing tabs May In and May out, and is only showing May In and so on with the other months , why?
3. I can not see all tabls, there is a way to put on the combo box "show all"

Hint: May In, May Out, June In, June Out,etc....December In, December Out are tabs


Sub DropDown1_Change()
Dim Target As String


Target = "I am a place holder"

If Cells(1, "A") = 1 Then
Target = "May In"

ElseIf (Cells(1, "A") = 2) Then
Target = "June In"

ElseIf (Cells(1, "A") = 3) Then
Target = "July In"

ElseIf (Cells(1, "A") = 4) Then
Target = "August In"

ElseIf (Cells(1, "A") = 5) Then
Target = "September In"

ElseIf (Cells(1, "A") = 6) Then
Target = "October In"

ElseIf (Cells(1, "A") = 7) Then
Target = "November In"

ElseIf (Cells(1, "A") = 8) Then
Target = "December In"

End If


Sheets("June In").Visible = ((Sheets("June In").Name = Target) Or (Target = ""))
Sheets("June Out").Visible = ((Sheets("June Out").Name = Target & "A") Or (Target = ""))
Sheets("July In").Visible = ((Sheets("July In").Name = Target) Or (Target = ""))
Sheets("July Out").Visible = ((Sheets("July Out").Name = Target & "A") Or (Target = ""))
Sheets("August In").Visible = ((Sheets("August In").Name = Target) Or (Target = ""))
Sheets("August Out").Visible = ((Sheets("August Out").Name = Target & "A") Or (Target = ""))
Sheets("September In").Visible = ((Sheets("September In").Name = Target) Or (Target = ""))
Sheets("September Out").Visible = ((Sheets("September Out").Name = Target & "A") Or (Target = ""))
Sheets("October In").Visible = ((Sheets("October In").Name = Target) Or (Target = ""))
Sheets("October Out").Visible = ((Sheets("October Out").Name = Target & "A") Or (Target = ""))
Sheets("November In").Visible = ((Sheets("November In").Name = Target) Or (Target = ""))
Sheets("November Out").Visible = ((Sheets("November Out").Name = Target & "A") Or (Target = ""))
Sheets("December In").Visible = ((Sheets("December In").Name = Target) Or (Target = ""))
Sheets("December Out").Visible = ((Sheets("December Out").Name = Target & "A") Or (Target = ""))
Sheets("KPI").Visible = ((Sheets("KPI").Name = Target & "A") Or (Target = ""))

End SubCan

Thanks for your help. Mary

2 replies

rizvisa1
Posts
4479
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
770
Jun 8, 2010 at 04:14 AM
The code does not match your data

let me try to explain the code as it is needed as original code was based on example. so lets first try to understand code

Sheets("June In").Visible = ((Sheets("June In").Name = Target) Or (Target = ""))

This line of code is deciding should it make "June In" tab be made visible or hidden

Sheets("June In").Visible
: true or false. Makes it visible or hide

((Sheets("June In").Name = Target) Or (Target = ""))
: Here it is being decided to make visible or false. It has two parts and if either part is true, then true is evaluated

A. Sheets("June In").Name = Target
B. Target = ""

In Part A, it is checking in the value of Target is same as name of the sheet "June In", which would be "June In". If is the case then True is evaluated

In Part B, it is checking if the value of Target was ""

In the same manner
Sheets("June Out").Visible = ((Sheets("June Out").Name = Target & "A") Or (Target = ""))


Sheets("June Out").Visible : same explanation as before

Sheets("June Out").Name = Target & "A" : This checks in the sheet name of "June Out", which would be "June out", is same as value of appended value of target and "A". So if Target was "June", this Target & "A" will be evaluated as "JuneA"
Target = "": Same as before

Hope now you see where you are making mistake



Change need.

1. Let target be equal to Month only like "June", instead of "June In"

2. For each Pair of sheet you need to have ( this is for JUNE only for example"

Sheets("June In").Visible = ((Sheets("June In").Name = Target & " In") Or (Target = ""))

Sheets("June Out").Visible = ((Sheets("June Out").Name = Target & " Out") Or (Target = ""))
0
Thank you so much I appreciated your help
0