How to use Cells.Find function to search only in one column?

dduranic

New Member
Joined
Dec 14, 2006
Messages
6
I want to find a content of ActiveCell only in column "C", beginning from cell C4.What must be in Look in, and Look at?How to accomplish to match whole number,ex. "1" in cell with "1",no to find "1" in "123"!

This function searches in whole sheet,but i need only in C column!
Cells.Find(What:=ActiveCell, After:=[c4], LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate

Please,help me!
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi, welcome to the board!

It's better to set it to a range object, rather than using Activate. This way you can check to see if anything was actually found or not.

I think this should do it for you:

Code:
Sub findit()
Dim c As Range
Set c = Range("C4:C65536").Find _
    (What:=ActiveCell, _
    LookIn:=xlValues, LookAt:=xlWhole, _
    SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False)
If Not c Is Nothing Then c.Select
End Sub

xlwhole in LookAt will look at the whole value of the cell rather than part of it.
 
Upvote 0
Thank you very much!!
That works fine.
I need to programm something in this macro,and if you know how,I would be greateful to help me!
I need to add the content (number) of the cell in D column behind the active cell in C column (same row) to the cel in D column in the same row where is the found cell.
For exampe,if the content of active cell is found in C10,I need to add the number in cell D (same row as the active cell) to the number in cell D (same row as the found cell)
How to do this?
 
Upvote 0
Will there be more than one of what you are searching for? Is what you are looking for a set value or do you want it to look for what is in the contents of a cell, any cell in particular?
 
Upvote 0
No,there will be only one of what I'm searching for!This cells in C and D column are only connected with row number.When it finds content of active cell in some cell in same column (C),i need to add number in cell in column D in the same row as the active cell, to a number in cell in column D of the same row where is the found cell in column C.There is nothing to work with found cell,only to use it's row number to calculate cells in D column.
 
Upvote 0
Perhaps:

Code:
Sub findit()
Dim c As Range
Set c = Range("C4:C65536").Find _
    (What:=ActiveCell, _
    LookIn:=xlValues, LookAt:=xlWhole, _
    SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False)
If Not c Is Nothing Then c.Offset(, 1) = c.Offset(, 1) + c
End Sub
 
Upvote 0
That functoin adds found cell in C to a D.I need to add cell in D to D.
Ex. active cell is C10,and i need to add D10 to a cell in D in the same row where it found cell in C.
 
Upvote 0
You lost me, you are searching for the value in the activecell, so the value it found should be the same value as in the activecell.

Also why is your activecell in the same column you are searching in, if you are clicked on the value you are searching for, you already know where it is.

What am I missing?
 
Upvote 0
Column C is identitiy number of product,and column C is quantity of that product.When I intput new ID for ex. in row 10000 it writes me a message in F column that this product whit same id is already written somewhere.I need to find it and add quantity of new intput in cell D to a quauantity of found record.
 
Upvote 0
OK, uncomment out this line
'ActiveCell.Resize(, 2).ClearContents
if you want it to clear the active cell and the value in Column D of the same row after it does it.

Code:
Sub findit()
Dim c As Range
Set c = Range("C4:C65536").Find _
    (What:=ActiveCell, _
    LookIn:=xlValues, LookAt:=xlWhole, _
    SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False)
If Not c Is Nothing Then
    c.Offset(, 1) = c.Offset(, 1) + ActiveCell.Offset(, 1)
    'ActiveCell.Resize(, 2).ClearContents
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,831
Messages
6,127,143
Members
449,363
Latest member
Yap999

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