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

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
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,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

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