mrfantastic
New Member
- Joined
- Oct 23, 2018
- Messages
- 2
Hello all:
Although I have been using Excel for many years, I am a relative novice to VBA, and am very new to Mr. Excel (my membership tenure is easily measurable in minutes). In any case, I am using a beginner-level VBA book to try to learn, but am stumped at one point (and I think the book may be wrong). In any case, the code I am on is meant to use a TabStrip control in a userform to manipulate worksheet data. Here’s the code I have right now…
The code stops with the cmdUpdate sub at the Select Case line (apparently the SelectedItemIndex method is invalid). In any case, please help me troubleshoot (preferably with a simple fix or fixes if possible). Thank you very much.
Although I have been using Excel for many years, I am a relative novice to VBA, and am very new to Mr. Excel (my membership tenure is easily measurable in minutes). In any case, I am using a beginner-level VBA book to try to learn, but am stumped at one point (and I think the book may be wrong). In any case, the code I am on is meant to use a TabStrip control in a userform to manipulate worksheet data. Here’s the code I have right now…
Code:
Option Explicit
Sub Populate()
Select Case tabPrf.SelectedItem.Index
Case 0
txtTgt.Value = Range("B2").Value
txtSls.Value = Range("B3").Value
Case 1
txtTgt.Value = Range("C2").Value
txtSls.Value = Range("C3").Value
End Select
lblPct.Caption = Format(txtSls.Value / txtTgt.Value, "0%")
End Sub
Private Sub Label1_Click()
End Sub
Private Sub UserForm_Initialize()
tabPrf.TabStrip1(0).Caption = Range("B1").Value
tabPrf.TabStrip1(1).Caption = Range("C1").Value
'tabPrf.Tabs(0).Caption = Range("B1").Value
'tabPrf.Tabs(1).Caption = Range("C1").Value
End Sub
Private Sub tabPrf_Change()
Populate
End Sub
Private Sub cmdUpdate_Click()
Select Case tabPrf.SelectedItemIndex
Case 0
Range("B2").Value = txtTgt.Value
Range("B3").Value = txtSls.Value
Case 1
Range("C2").Value = txtTgt.Value
Range("C3").Value = txtSls.Value
End Select
lblPct.Caption = Format(txtSls.Value / txtTgt.Value, "0%")
End Sub
The code stops with the cmdUpdate sub at the Select Case line (apparently the SelectedItemIndex method is invalid). In any case, please help me troubleshoot (preferably with a simple fix or fixes if possible). Thank you very much.