help with cells.find

steve-m

New Member
Joined
Jul 6, 2011
Messages
5
Hi

is there anyway using cell.find i can find an exact match on the number 0?

e.g
i have a column with value 0 and 111.07 i only want to find 0 values

example
Code:
Cells.Find(What:=0, After:=Cells(17, 17), LookIn:=xlValues, LookAt:= _
    xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
    , SearchFormat:=False).Activate
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Try

Rich (BB code):
Cells.Find(What:=0, After:=Cells(17, 17), LookIn:=xlValues, LookAt:= _
    xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
    , SearchFormat:=False).Activate
 
Upvote 0
thanks for the reply's, that's done the trick. i have another question if you could help?

using

After:=Cells(32, 18)

i need to look in column 18 for zero values but the row position 32 is variable is there a way to do that?
 
Upvote 0
Maybe like this where iRow holds the row number

Code:
Cells.Find(What:=0, After:=Cells(iRow, 18), LookIn:=xlValues, LookAt:= _
    xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
    , SearchFormat:=False).Activate
 
Upvote 0
I'm relatively new to vba could you please explain irow works?

further info:
I'm trying to use the cells.find to find the first "0" in column 18 an insert three blank rows above the code below is working apart from data i import to excel is different every time the macro runs.

Code:
Cells.Find(What:=0, After:=Cells(32, 18), LookIn:=xlValues, LookAt:= _
    xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
    , SearchFormat:=False).Activate
    
    'The following line of code moves down two cells from "CFP Data ID"
    Selection.Offset(-1, 0).Select
    Dim Rng, n As Long, k As Long

    'These two lines of code fetch the number of rows you want to insert into the sheet
    'Rng = InputBox("Enter number of rows required.")
    If Rng = 1 Then Exit Sub
    
    'This line inserts a new row
    Range(ActiveCell, ActiveCell.Offset(Val(Rng) + 3, 0)).EntireRow.Insert
 
Upvote 0
nothing - i'm trying to search within column 18 to find the starting row.

i may need to rethink this code and do a loop on the rows to find the first value of "0" in column 18
 
Last edited:
Upvote 0
Maybe omit the After argument and limit the search to column 18

Code:
Columns(18).Find(What:=0, LookIn:=xlValues, LookAt:= _
    xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
    , SearchFormat:=False).Activate
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,289
Members
452,902
Latest member
Knuddeluff

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