Search row of data for numbers not negative or in parenthesis

ThomasOES

Board Regular
Joined
Aug 29, 2017
Messages
174
I need vba to search down a column from cell D1 to the end of the data. The length of the column of data varies. I need the first cell that is non-negative and no parenthesis.
Below is a sample column. I need to start the search with the cell below C and then select the cell with 0.026.

[TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64, bgcolor: transparent"]C[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]-3[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]-3[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]-3[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]-2[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]-2[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"](0.023)[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]0.026[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]0.0367[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]0.04[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]0.05[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]0.051[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]0.052[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]0.055[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]0.106

Thanks

Tom
[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Assuming that your parentheses represent negative numbers, then you could use a simple loop to do it, like this:
Code:
Sub FirstPositive()

    Dim myRow As Long
    
    myRow = 1
    Do
        If Cells(myRow, "D") > 0 Then Exit Do
        myRow = myRow + 1
    Loop
    Cells(myRow, "D").Select
    
End Sub
 
Upvote 0
Thanks Joe
Your code works. Sorry about the extra submission. I wasn't sure my question made sense.

Tom
 
Upvote 0
You are welcome.

If you are ever unsure if it is clear, you can post clarifications back to the original post. I would just wait a little while, as posting back to it removes it from the "Zero Reply Posts" listing that many of us use to look for unanswered questions.
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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