![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Posts: 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. |
|
|
|
|
|
#2 |
|
BatCoder
Join Date: Feb 2002
Location: Turkey
Posts: 764
|
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 |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Mar 2002
Posts: 101
|
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. |
|
|
|
|
|
#4 |
|
BatCoder
Join Date: Feb 2002
Location: Turkey
Posts: 764
|
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 ] |
|
|
|
|
|
#5 |
|
BatCoder
Join Date: Feb 2002
Location: Turkey
Posts: 764
|
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 |
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Mar 2002
Posts: 101
|
Thanks smozgur, your routine works just fine.
|
|
|
|
|
|
#7 |
|
BatCoder
Join Date: Feb 2002
Location: Turkey
Posts: 764
|
you're welcome.
|
|
|
|
|
|
#8 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
|
Quote:
|
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|