Array does not like #NAME?

Reset

Board Regular
Joined
Apr 16, 2010
Messages
227
I am running the following code that looks for a user input value (fname) in a specified column (cname). If it's there, another array notes the row. Then I go back and fill the array with the cell values of the rows with hits (Note: thanks to VoG on last issue). Then it's all dumped into another sheet (workbook=b2name and sheet=s2name). Here's the code:

m = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByColumns).Column
a = Application.WorksheetFunction.CountA(Columns(cname))
ReDim rcount(a) As Integer
For x = 1 To a
If InStr(1, Cells(x, cname), fname, 1) Then
inc = inc + 1
rcount(inc) = x
End If
Next x
ReDim rdata(inc, m) As String
For x = 1 To inc
For y = 1 To m
rdata(x, y) = Cells(rcount(x), y)
Next y
Next x
Workbooks(b2name).Activate
Sheets(s2name).Activate
For x = 1 To inc
For y = 1 To m
Cells(x, y) = rdata(x, y)
Next y
Next x

However, when it reaches a cell with #NAME? I get a Run-time error '13': Type mismatch. In the editor the highlighted area "rdata(x, y) = Cells(rcount(x), y) also gives Cells(rcount(x), y) = Error 2029. Does anyone know how to ignore this? I could just fill the spot in the array with a dummy value. Thanks.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Try

Code:
If Not IsError(Cells(rcount(x), y)) Then
    rdata(x, y) = Cells(rcount(x), y)
End If
 
Upvote 0

Forum statistics

Threads
1,216,496
Messages
6,130,984
Members
449,612
Latest member
geniusufo007

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