Finding a value in a list

Josue Barocio

Board Regular
Joined
Mar 8, 2002
Messages
101
I need to find the first zero value in a sorted (descending) list.
The FIND function fails because it finds the first zero character, as in 20, 30, etc.
Thanks in advance for your help.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Can you explain first zero value by sample data column please?

And are you looking for a function? So you would get the cell address etc?

regards
 
Upvote 0
I need to position cursor on the first zero value in a list such as the following:
98
40
20
0
0

I would then insert a row at the first zero value and perform other sorts on the records above the zeroes.
 
Upvote 0
Call the sub like below:

Call FindValue(Range("A20:A40"),0)

Sub FindValue(rng As Range, lookupval)
For i = 1 To rng.Rows.Count
If rng(i, rng.Column) = lookupval Then
rng(i, rng.Column).Activate
MsgBox "Perform Whatever You Want"
Exit For
End If
Next i
End Sub

It will find the first cell includes lookup value (0 for you) and activate the cell.

regards

_________________
Oz ~ TheWordExpert
This message was edited by smozgur on 2002-04-06 19:19
 
Upvote 0
hmm, to insert a row above this row:

Sub FindValue(rng As Range, lookupval)
For i = 1 To rng.Rows.Count
If rng(i) = lookupval Then
Rows(rng(i).Row).Insert
MsgBox "Perform Whatever You Want"
Exit For
End If
Next i
End Sub

to just insert a new cell (not whole row)

Sub FindValue(rng As Range, lookupval)
For i = 1 To rng.Rows.Count
If rng(i) = lookupval Then
rng(i).Select
ActiveCell.Insert Shift:=xlShiftDown
MsgBox "Perform Whatever You Want"
Exit For
End If
Next i
End Sub
 
Upvote 0
On 2002-04-06 18:19, Josue Barocio wrote:
I need to find the first zero value in a sorted (descending) list.
The FIND function fails because it finds the first zero character, as in 20, 30, etc.
Thanks in advance for your help.

The FIND [command] doesn't "fail" if you check the "Find entire cells only" box.
 
Upvote 0

Forum statistics

Threads
1,213,530
Messages
6,114,163
Members
448,554
Latest member
Gleisner2

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