issues in a For Each ... Next loop

StrawS

Board Regular
Joined
Jul 31, 2006
Messages
123
I'm having troubles with a For Each ... Next loop.

I'm not sure how much of my code I should post so I'll start on the lean side and if anyone needs more context - just ask.

Code:
For Each cell In Sheets("database").Columns("A")
    If cell.Value = TextBox7.Text Then
        n = n + 1
        If n > UBound(a, 2) Then ReDim Preserve a(1 To 8, 0 To n)
        a(1, n) = cell.Row
    End If
Next

The error message is "Run-time error '13': Type mismatch", generated by the second line I posted.

I have a hunch the error is coming from the cell.value section.

If anyone can shed light on the situation, please let me know.

Thanks.

Straws
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Then I don't understand why the results are the same....

The cell value formated as Date should be Long like 33456, so that you can compre with other Date type data, but not with String type data like "02/02/06".

Sorry but I don't know about it...
 
Upvote 0

Forum statistics

Threads
1,215,963
Messages
6,127,954
Members
449,412
Latest member
montand

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