I have a Worksheet with the names of 34 different TextBox's in column 4. In column 5 I have the names of various colors. In column 6 I have the name of a Sub, for example
tbxCat1 vbYellow TextBoxSettings1
tbxCat2 vbCyan TextBoxSettings1 <==========There are 6 different TextBoxSettings Subs
etc.
I read all of these into two arrays:
Dim tbxName() As String
Dim tbxColor() As String
Dim tbxSubs() As String
Dim N As Integer
At some random point in the program I'll call a subroutine, for example:
Call TextBoxControl(21) ' Recomended Retail Price TextBox
Sub TextBoxControl(N As Integer)
Set MyControl = Me.Controls(tbxName(N))
Select Case tbxSubs(N)
Case TextBoxSettings1
Call TextBoxSettings1(MyControl, "", tbxColor(N)) <=======I get a Run-time error '13' Type mismatch. I've replaced tbxColor(N) with vbYellow, but still get the same error
Case TextBoxSettings2
etc. etc.
End Sub
Sub TextBoxSettings1(ByRef tbx As MSForms.TextBox, tbxValue, tbxColour)
tbx.Value = tbxValue
tbx.BackColor = tbxColour
tbx.ForeColor = vbBlack
tbx.SpecialEffect = fmSpecialEffectSunken
tbx.BorderStyle = fmBorderStyleNone
End Sub
Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #2 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
I think the error is something to do with "Dim tbxName() As String"
Can anyone advice?
Regards
Joe
Bookmarks