Hello all,
Please help! I am stuck on how to get round with this problem. I kept getting this error message when I click "OK" from the userform.
Runtime error '-2147024809 (80070057)'
The item with the specific name wasn't found.
when I click debug, the code it highlights is: sht.Range(headerArr(a * 2)) = Controls("TextBox" & (a + 1))
Thank you guys.
Please help! I am stuck on how to get round with this problem. I kept getting this error message when I click "OK" from the userform.
Runtime error '-2147024809 (80070057)'
The item with the specific name wasn't found.
when I click debug, the code it highlights is: sht.Range(headerArr(a * 2)) = Controls("TextBox" & (a + 1))
Thank you guys.
Code:
Option Compare Text
Const header = "C12,a ,k22,a ,o22,a ,n23,a ,v23,a ,n24,a ,v24,a ,n25,a ,x25,a ,e30,a ,e31,a ,d44,a"
Const mySheet = "Sheet1"
Dim a, b, aa, bb
Private Sub UserForm_Initialize()
If tmpfmen = "" And tmpwken = "" Then
CmdUndo.Enabled = False
Else
CmdUndo.Enabled = True
End If
a = UniqueArrayByDict([Agency].Value, 1)
a = advArrayListSort(a)
ListBox1.List = a
aa = UniqueArrayByDict([Reason].Value, 1)
aa = advArrayListSort(aa)
ListBox2.List = aa
End Sub
Private Sub cmdClearEntry_Click()
For Each ctl In Controls
If TypeName(ctl) = "TextBox" Then ctl.Text = vbNullString
Next
a = UniqueArrayByDict([Agency].Value, 1)
a = advArrayListSort(a)
With ListBox1
.List = a
.ListIndex = 0
End With
'TextBox1.BackColor = 16777215
End Sub
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
TextBox1.Value = ListBox1.Value
End Sub
Private Sub ListBox2_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
TextBox10.Value = ListBox2.Value
End Sub
Private Sub CommandButton1_Click()
If UBound(headerArr) Mod 2 <> 1 Then MsgBox "Error in Cell Address & Header pair"
For a = 0 To (UBound(headerArr) - 1) / 2
Range(headerArr(a * 2)).Offset(0, 1) = InputBox(headerArr(a * 2 + 1), "Field Entry")
Next
End Sub
Private Sub cmdOK_Click()
headerArr = Split(header, ",")
Set sht = Worksheets(mySheet)
For a = 0 To (UBound(headerArr) - 1) / 2
sht.Range(headerArr(a * 2)) = Controls("TextBox" & (a + 1))
Sheet1.[C12].Value = ListBox1.Value
Sheet1.[E30].Value = ListBox2.Value
Next
End Sub
Private Sub TextBox1_Change()
'Ken, added:
Dim s As String, b
If Me.TextBox1.Value = "" Then
Me.TextBox1.BackColor = &HFFFF&: Exit Sub
Else
TextBox1.BackColor = 16777215
End If
TextBox1.Value = UCase(TextBox1.Value)
'Ken, added:
s = TextBox1.Value
If Not IsArray(b) Then b = a
b = Filter(b, s) 'case sensitive
b = Filter(b, s, True, vbTextCompare) 'case insensitive
ListBox1.List = b
End Sub
Private Sub TextBox1_Enter()
Me.TextBox1.BackColor = &HFFFF&
Me.TextBox1.Value = ""
With Sheets("Agency")
'.Unprotect
'.Range("IV:IV").ClearContents
.Protect
End With
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Me.TextBox1.BackColor = 16777215
End Sub
Private Sub TextBox10_Change()
'Ken, added:
Dim s As String
If Me.TextBox10.Value = "" Then
Me.TextBox10.BackColor = &HFFFF&
Else
TextBox10.BackColor = 16777215
End If
TextBox10.Value = UCase(TextBox10.Value)
s = TextBox10.Value
If s = "" Then
ListBox2.List = aa
Else
bb = Filter(aa, s, True, vbTextCompare) 'case insensitive
ListBox2.List = bb
End If
End Sub
Private Sub TextBox10_Enter()
Me.TextBox1.BackColor = &HFFFF&
Me.TextBox1.Value = ""
With Sheets("Reason")
'.Unprotect
'.Range("IV:IV").ClearContents
.Protect
End With
End Sub
Private Sub TextBox10_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Me.TextBox10.BackColor = 16777215
End Sub