RUN-time error '-2147024809 (80070057)

RJ1969

Board Regular
Joined
Sep 13, 2014
Messages
76
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.

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
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
@RJ1969,

Please take a minute to read the forum rules, especially as regards cross-posting, and comply with them in future. Thanks. :)
 
Upvote 0

Forum statistics

Threads
1,215,370
Messages
6,124,526
Members
449,169
Latest member
mm424

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