Hi
here is the orginal code
Private Sub TextBox1_Change()
If InStr(1, TextBox1.Value, "SALES INVOICE NO", vbTextCompare) > 0 Then
TextBox2.Locked = False
TextBox3.Locked = True
TextBox2.SetFocus
ElseIf InStr(1, TextBox1.Value, "CASH PAID", vbTextCompare) > 0 Then
TextBox2.Locked = True
TextBox3.Locked = False
TextBox2.SetFocus
Else
'And if there is no "expenses" or "revenue", the textboxes are locked
'if you want unlocked, change to False
TextBox2.Locked = True
TextBox3.Locked = True
End If
End Sub
my goal puttin multiple words in one line into array to avoid writing many lines for each word , then the code will become big in writing many lines
I try make short code like this as in bold lines
Private Sub TextBox1_Change()
Dim ARR As Variant
ARR = Array("SALES INVOICE NO", "CASH PAID")
If InStr(1, TextBox1.Value, ARR, vbTextCompare) > 0 Then
TextBox2.Locked = False
TextBox3.Locked = True
TextBox2.SetFocus
Else
'And if there is no "expenses" or "revenue", the textboxes are locked
'if you want unlocked, change to False
TextBox2.Locked = True
TextBox3.Locked = True
End If
End Sub
but gives mismatch error in this line
If InStr(1, TextBox1.Value, ARR, vbTextCompare) > 0 Then
the code will lock textbox3 based on words are filled in textbox1.
by the way this is the part of my project , so there is no commandbutton to copy to sheet , before I copy to sheet .I have to solve this part !
any help to chieve this ,please?