# Array Function problem

#### lucky12341

##### Board Regular
This command keeps giving me an error message, this is what is highlighted, MyArray(0, 1) = head1, any ideas whats wrong?

Private Sub CommandButton14_Click()
Dim strFind As String
Dim rSearch As Range
Dim fndA, fndB, fndC, fndD, fndE, fndF, fndG, fndH, fndI As String
Dim i As Integer
i = 1
Set rSearch = Sheet10.Range("b2", Range("b65536").End(xlUp))
strFind = Me.TextBox2.Value
With rSearch
Set c = .Find(strFind, LookIn:=xlValues)
If Not c Is Nothing Then
c.Select
With Me.ListBox1
End With
Do
fndB = c.Value
fndA = c.Offset(0, -1).Value
fndC = c.Offset(0, 2).Value
fndD = c.Offset(0, 3).Value
fndE = c.Offset(0, 4).Value
fndF = c.Offset(0, 5).Value
fndG = c.Offset(0, 6).Value
fndH = c.Offset(0, 7).Value
fndI = c.Offset(0, 8).Value

MyArray(i, 0) = fndA
MyArray(i, 1) = fndB
MyArray(i, 2) = fndC
MyArray(i, 3) = fndD
MyArray(i, 4) = fndE
MyArray(i, 5) = fndF
MyArray(i, 6) = fndG
MyArray(i, 7) = fndH
MyArray(i, 8) = fndI
i = i + 1
Set c = .FindNext(c)

End If
End With
Me.ListBox1.List() = MyArray
End Sub

### Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Have you declared and dimensioned MyArray as a 2-D array? I do not see it.

No how do I do that (new to VBA)

Replies
10
Views
622
Replies
4
Views
240
Replies
5
Views
1K
Replies
1
Views
137
Replies
3
Views
348

1,212,144
Messages
6,106,218
Members
448,006
Latest member
oreo2996

### 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.

### Which adblocker are you using?

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

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