search column for data & add name in cells next to them

berty2000

Board Regular
Joined
Mar 29, 2011
Messages
71
Hi guys

Trying to make a macro that will search a column for names and when it finds them paste the word "Task Complete" in the cells next to the names.

Any blank cells leave blank.

My thinking was add a formula in the column M4:M200 that would search for any entry in the column and if found in column N4:N200 enter the word next to it.

This is what iv'e played around with but can't get right :(

Sub checknames()

' Select all blank cells in range M4:M200
Range("M4:M200").SpecialCells(xlCellTypeBlanks).Select
' Enter formula in these blank cells
Selection.Formula = "=IF(ISERROR(SEARCH("",M4,1)),"","Task Complete ")"

End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hello berty2000,

Can you give me an example using the cells? Which column has the names?
 
Upvote 0
names are in column M going down

86amse387
 
Upvote 0
Hello berty2000,

I'm still having trouble understanding this. What is the search term and where is it located?

Let's say Berty is in M4. Would the macro then search N4:N200 for this name?
 
Upvote 0
The names go down in column M like Peter jan sue then in column N alongside the names I want task complete to come up
 
Upvote 0
Hello berty2000,

It looks like you want the "Task Complete" to appear in column "N" whenever a the adjacent cell in column "M" is not empty. Add this formula to cell N4 then drag it down to N200.
=IF(M4="","","Task Complete")
 
Upvote 0
Thats correct but I need to be able to run it all from a macro so i can press a button and it will do it automatically when I need it
 
Upvote 0
Hello berty2000,

Sorry, you did you wanted a macro.

Code:
Sub MarkCompleted()

    Dim Cell As Range
    
        For Each Cell In Range("M4:M200")
            If Cell <> "" Then Cell.Offset(0, 1) = "Task Complete"
        Next Cell

End Sub
 
Upvote 0

Forum statistics

Threads
1,203,244
Messages
6,054,366
Members
444,719
Latest member
saathvik

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