Excel 2016: Select case troubleshooting

jedwardo

Board Regular
Joined
Aug 21, 2012
Messages
122
Having trouble wrapping my head around condensing this. The blue version is working, the black version is working, but the green is what I'm trying to make happen but not sure how to go about it. It's making "test" a value of zero rather than copying q to test. I get why just not the how to.

Code:
Private Sub TabStrip1_Change()

Dim q As Integer
Dim varTab As Variant
Dim test As Variant

Me.TextBox5.SetFocus

[COLOR=#0000ff]'        varTab = Me.TabStrip1.SelectedItem.Caption
'        q = Me.TextBox5.Value
'            Select Case varTab
'                Case Is = "Base"
'                    Me.TextBox0.Value = q
'                Case Is = "Crown"
'                    Me.TextBox1.Value = q
'                Case Is = "Chairrail"
'                    Me.TextBox2.Value = q
'                Case Is = "Jambs"
'                    Me.TextBox3.Value = q
'            End Select

[/COLOR][COLOR=#000000]        varTab = Me.TabStrip1.Value
        q = Me.TextBox5.Value
 [/COLOR][COLOR=#b22222] [/COLOR][COLOR=#008000]      test = Me("Textbox" & varTab).Value[/COLOR][COLOR=#000000]
[/COLOR]
            Select Case varTab
                Case Is = 0, Is = 1, Is = 2, Is = 3

                   Me("Textbox" & varTab).Value = q
 [COLOR=#008000]                  'test = q[/COLOR]

            End Select
       
End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
If you wanted to copy the value of q to test the code would look like this.
Code:
test = q
 
Upvote 0
That's what I was thinking. This line of code is doing that fine:
Code:
[LEFT][COLOR=#333333][FONT=monospace]Me("Textbox" & varTab).Value = q[/FONT][/COLOR][/LEFT]


Was trying to accomplish the same with these but just end up making test = 0 instead of copying from textbox5 to textbox0.
Code:
[FONT=Consolas][SIZE=2][COLOR=#008000]test = Me("Textbox" & varTab).Value
[/COLOR][/SIZE][/FONT][LEFT][COLOR=#333333][FONT=monospace][SIZE=2][COLOR=#008000]test = q[/COLOR][/SIZE][/FONT][/COLOR][/LEFT]
 
Upvote 0

Forum statistics

Threads
1,214,907
Messages
6,122,185
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top