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