find and give value in next cell - Need Simple Formula

VBABEGINER

Well-known Member
Joined
Jun 15, 2011
Messages
1,232
Hi Experts,

I want below code in formula.. Pls assist..

tpa = is a word available in cell

wherever i will find tpa, next cell of that should be return 1 or 0

Code:
Dim myRange As Range
Dim myCell As Range
rng = Range("B" & Rows.Count).End(xlUp).Row
Set myRange = Range("B2:B" & rng)




'example=  ABC tpa PQR


For Each myCell In myRange
    If myCell Like "*tpa*" Then 
        
    end if
next
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Try Offset:

Code:
x = myCell.Offset(,1)

Hi Eric, Thanks for reply.. But i didnt get what you tried to say. The code which i posted that too written by me, i got from mrexcel only..

Pls give me formula instead.. Thanks
 
Upvote 0
I gave you a VBA answer because you posted VBA code and apparently wanted it updated. As it is, that code doesn't do anything. If you want a worksheet formula, that's possible, but you need to be specific as to what you want. It appears you want to search a range, look for "*tpa*" and if found, return the value to the right of it. If so, try

=SUMIF(A1:A5,"*tpa*",B1:B5)

But what do you want to do in case there are multiple matches? It might help if you could provide examples of what you want.
 
Upvote 0
I gave you a.....
But what do you want to do in case there are multiple matches? It might help if you could provide examples of what you want.

Hi Eric, Thank you for your valuable reply and time...

Yes, i do have 65,000 data in col A. In certain cell's there is "tpa" word either single or placed with other text too..

I wanted if, *tpa* present in Col A cell then it should return 1 in cell of Col B else, return 0.

Hope this is description im help you understand.. :)
 
Upvote 0
That should work. You can remove the =0 from the formula if you want. Thanks for the update. Glad you found something that works for you.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

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