Looking string inside cell Text (VB)What is the difference between String and string in C#?How do I iterate over the words of a string?How do I read / convert an InputStream into a String in Java?Case insensitive 'Contains(string)'How do I make the first letter of a string uppercase in JavaScript?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?Does Python have a string 'contains' substring method?How do I convert a String to an int in Java?Why is char[] preferred over String for passwords?

Confusion about off peak timings of London trains

Random Unitary Matrices

Arriving at the same result with the opposite hypotheses

Why is one of Madera Municipal's runways labelled with only "R" on both sides?

Passing multiple files through stdin (over ssh)

PhD - Well known professor or well known school?

How is water heavier than petrol, even though its molecular weight is less than petrol?

Why would future John risk sending back a T-800 to save his younger self?

What's up with this leaf?

What's the name of this light airplane?

What should the arbiter and what should have I done in this case?

What risks are there when you clear your cookies instead of logging off?

Was the output of the C64 SID chip 8 bit sound?

Payment instructions allegedly from HomeAway look fishy to me

Winning Strategy for the Magician and his Apprentice

Do any instruments not produce overtones?

Was there a priest on the Titanic who stayed on the ship giving confession to as many as he could?

Smooth switching between 12 V batteries, with a toggle switch

Is an early checkout possible at a hotel before its reception opens?

What does the term "railed" mean in signal processing?

Why was the Sega Genesis marketed as a 16-bit console?

Is using haveibeenpwned to validate password strength rational?

When conversion from Integer to Single may lose precision

Implement Homestuck's Catenative Doomsday Dice Cascader



Looking string inside cell Text (VB)


What is the difference between String and string in C#?How do I iterate over the words of a string?How do I read / convert an InputStream into a String in Java?Case insensitive 'Contains(string)'How do I make the first letter of a string uppercase in JavaScript?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?Does Python have a string 'contains' substring method?How do I convert a String to an int in Java?Why is char[] preferred over String for passwords?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm looping row inside sheet and I want to find string inside some text:



lr = ws.Cells(Rows.Count, "A").End(xlUp).Row
lrk = wsK.Cells(Rows.Count, "A").End(xlUp).Row

For i = 2 To lr --looping list
look_name = UCase(ws.Range("E" & i).Value)

For j = 2 To lrk --loop patern value
look_text = UCase(wsK.Range("A" & j).Value)

If look_name Like "*look_text*" Then --if found
ws.Range("AB" & i) = wsK.Range("B" & j).Value --to do
Exit For
End If

Next j
Next i


I think something wrong I did with "*look_text*"



If look_name = "New city" and look_text = "city", it's not going into IF.










share|improve this question



















  • 1





    Why do you think you did something wrong with "*look_text*"?

    – Ron Rosenfeld
    Mar 24 at 16:31












  • On my test data it's not working, maybe somewhere else is mostake....

    – 4est
    Mar 24 at 16:33











  • What, exactly, do you mean by not working?

    – Ron Rosenfeld
    Mar 24 at 16:34











  • You should probably read the HELP topics for How do I Ask a Good Question, and also How to create a Minimal, Complete, and Verifiable example. Then edit your post to provide information that will enable the group to help you.

    – Ron Rosenfeld
    Mar 24 at 16:35











  • It's not going inside if , when the string is inside my text

    – 4est
    Mar 24 at 16:37

















0















I'm looping row inside sheet and I want to find string inside some text:



lr = ws.Cells(Rows.Count, "A").End(xlUp).Row
lrk = wsK.Cells(Rows.Count, "A").End(xlUp).Row

For i = 2 To lr --looping list
look_name = UCase(ws.Range("E" & i).Value)

For j = 2 To lrk --loop patern value
look_text = UCase(wsK.Range("A" & j).Value)

If look_name Like "*look_text*" Then --if found
ws.Range("AB" & i) = wsK.Range("B" & j).Value --to do
Exit For
End If

Next j
Next i


I think something wrong I did with "*look_text*"



If look_name = "New city" and look_text = "city", it's not going into IF.










share|improve this question



















  • 1





    Why do you think you did something wrong with "*look_text*"?

    – Ron Rosenfeld
    Mar 24 at 16:31












  • On my test data it's not working, maybe somewhere else is mostake....

    – 4est
    Mar 24 at 16:33











  • What, exactly, do you mean by not working?

    – Ron Rosenfeld
    Mar 24 at 16:34











  • You should probably read the HELP topics for How do I Ask a Good Question, and also How to create a Minimal, Complete, and Verifiable example. Then edit your post to provide information that will enable the group to help you.

    – Ron Rosenfeld
    Mar 24 at 16:35











  • It's not going inside if , when the string is inside my text

    – 4est
    Mar 24 at 16:37













0












0








0








I'm looping row inside sheet and I want to find string inside some text:



lr = ws.Cells(Rows.Count, "A").End(xlUp).Row
lrk = wsK.Cells(Rows.Count, "A").End(xlUp).Row

For i = 2 To lr --looping list
look_name = UCase(ws.Range("E" & i).Value)

For j = 2 To lrk --loop patern value
look_text = UCase(wsK.Range("A" & j).Value)

If look_name Like "*look_text*" Then --if found
ws.Range("AB" & i) = wsK.Range("B" & j).Value --to do
Exit For
End If

Next j
Next i


I think something wrong I did with "*look_text*"



If look_name = "New city" and look_text = "city", it's not going into IF.










share|improve this question
















I'm looping row inside sheet and I want to find string inside some text:



lr = ws.Cells(Rows.Count, "A").End(xlUp).Row
lrk = wsK.Cells(Rows.Count, "A").End(xlUp).Row

For i = 2 To lr --looping list
look_name = UCase(ws.Range("E" & i).Value)

For j = 2 To lrk --loop patern value
look_text = UCase(wsK.Range("A" & j).Value)

If look_name Like "*look_text*" Then --if found
ws.Range("AB" & i) = wsK.Range("B" & j).Value --to do
Exit For
End If

Next j
Next i


I think something wrong I did with "*look_text*"



If look_name = "New city" and look_text = "city", it's not going into IF.







excel vba string






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 7:13









Pᴇʜ

27.3k63052




27.3k63052










asked Mar 24 at 16:26









4est4est

1,06341533




1,06341533







  • 1





    Why do you think you did something wrong with "*look_text*"?

    – Ron Rosenfeld
    Mar 24 at 16:31












  • On my test data it's not working, maybe somewhere else is mostake....

    – 4est
    Mar 24 at 16:33











  • What, exactly, do you mean by not working?

    – Ron Rosenfeld
    Mar 24 at 16:34











  • You should probably read the HELP topics for How do I Ask a Good Question, and also How to create a Minimal, Complete, and Verifiable example. Then edit your post to provide information that will enable the group to help you.

    – Ron Rosenfeld
    Mar 24 at 16:35











  • It's not going inside if , when the string is inside my text

    – 4est
    Mar 24 at 16:37












  • 1





    Why do you think you did something wrong with "*look_text*"?

    – Ron Rosenfeld
    Mar 24 at 16:31












  • On my test data it's not working, maybe somewhere else is mostake....

    – 4est
    Mar 24 at 16:33











  • What, exactly, do you mean by not working?

    – Ron Rosenfeld
    Mar 24 at 16:34











  • You should probably read the HELP topics for How do I Ask a Good Question, and also How to create a Minimal, Complete, and Verifiable example. Then edit your post to provide information that will enable the group to help you.

    – Ron Rosenfeld
    Mar 24 at 16:35











  • It's not going inside if , when the string is inside my text

    – 4est
    Mar 24 at 16:37







1




1





Why do you think you did something wrong with "*look_text*"?

– Ron Rosenfeld
Mar 24 at 16:31






Why do you think you did something wrong with "*look_text*"?

– Ron Rosenfeld
Mar 24 at 16:31














On my test data it's not working, maybe somewhere else is mostake....

– 4est
Mar 24 at 16:33





On my test data it's not working, maybe somewhere else is mostake....

– 4est
Mar 24 at 16:33













What, exactly, do you mean by not working?

– Ron Rosenfeld
Mar 24 at 16:34





What, exactly, do you mean by not working?

– Ron Rosenfeld
Mar 24 at 16:34













You should probably read the HELP topics for How do I Ask a Good Question, and also How to create a Minimal, Complete, and Verifiable example. Then edit your post to provide information that will enable the group to help you.

– Ron Rosenfeld
Mar 24 at 16:35





You should probably read the HELP topics for How do I Ask a Good Question, and also How to create a Minimal, Complete, and Verifiable example. Then edit your post to provide information that will enable the group to help you.

– Ron Rosenfeld
Mar 24 at 16:35













It's not going inside if , when the string is inside my text

– 4est
Mar 24 at 16:37





It's not going inside if , when the string is inside my text

– 4est
Mar 24 at 16:37












2 Answers
2






active

oldest

votes


















2














Another option, since you are adding wild-card * in the beginning and the end of your String, is to use Instr Function.



If Instr(look_name, look_text) > 0 Then



Edit 1: with text provided from PO



If InStr("abcabc testa abcbc", "test") > 0 Then
MsgBox "Instr Works"
End If





share|improve this answer

























  • I have tested your code and it's not working, when I change it to If InStr(look_name, look_text) > 0 then is working correctly

    – 4est
    Mar 25 at 8:16











  • @4est it's "look_text" , you need to add the "

    – Shai Rado
    Mar 25 at 12:09











  • no, I need to use & to connect parameter, without this is not working

    – 4est
    Mar 25 at 13:13












  • @4est if you can give me the string you need to check trust me it will work. The Instr will give you the same result as using Like "*" & look_text & "*"

    – Shai Rado
    Mar 25 at 13:17











  • I have checked all possibility with string (at beginning, in the middle, at end) and it's not working, sorry

    – 4est
    Mar 25 at 18:18



















1














I managed to solve the issue by changing



If look_name Like "*look_text*" Then


to



If look_name Like "*" & look_text & "*" Then





share|improve this answer

























  • Thank you @Vadim for adjust answer

    – 4est
    Mar 24 at 20:47











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55325948%2flooking-string-inside-cell-text-vb%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Another option, since you are adding wild-card * in the beginning and the end of your String, is to use Instr Function.



If Instr(look_name, look_text) > 0 Then



Edit 1: with text provided from PO



If InStr("abcabc testa abcbc", "test") > 0 Then
MsgBox "Instr Works"
End If





share|improve this answer

























  • I have tested your code and it's not working, when I change it to If InStr(look_name, look_text) > 0 then is working correctly

    – 4est
    Mar 25 at 8:16











  • @4est it's "look_text" , you need to add the "

    – Shai Rado
    Mar 25 at 12:09











  • no, I need to use & to connect parameter, without this is not working

    – 4est
    Mar 25 at 13:13












  • @4est if you can give me the string you need to check trust me it will work. The Instr will give you the same result as using Like "*" & look_text & "*"

    – Shai Rado
    Mar 25 at 13:17











  • I have checked all possibility with string (at beginning, in the middle, at end) and it's not working, sorry

    – 4est
    Mar 25 at 18:18
















2














Another option, since you are adding wild-card * in the beginning and the end of your String, is to use Instr Function.



If Instr(look_name, look_text) > 0 Then



Edit 1: with text provided from PO



If InStr("abcabc testa abcbc", "test") > 0 Then
MsgBox "Instr Works"
End If





share|improve this answer

























  • I have tested your code and it's not working, when I change it to If InStr(look_name, look_text) > 0 then is working correctly

    – 4est
    Mar 25 at 8:16











  • @4est it's "look_text" , you need to add the "

    – Shai Rado
    Mar 25 at 12:09











  • no, I need to use & to connect parameter, without this is not working

    – 4est
    Mar 25 at 13:13












  • @4est if you can give me the string you need to check trust me it will work. The Instr will give you the same result as using Like "*" & look_text & "*"

    – Shai Rado
    Mar 25 at 13:17











  • I have checked all possibility with string (at beginning, in the middle, at end) and it's not working, sorry

    – 4est
    Mar 25 at 18:18














2












2








2







Another option, since you are adding wild-card * in the beginning and the end of your String, is to use Instr Function.



If Instr(look_name, look_text) > 0 Then



Edit 1: with text provided from PO



If InStr("abcabc testa abcbc", "test") > 0 Then
MsgBox "Instr Works"
End If





share|improve this answer















Another option, since you are adding wild-card * in the beginning and the end of your String, is to use Instr Function.



If Instr(look_name, look_text) > 0 Then



Edit 1: with text provided from PO



If InStr("abcabc testa abcbc", "test") > 0 Then
MsgBox "Instr Works"
End If






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 26 at 12:19

























answered Mar 24 at 17:42









Shai RadoShai Rado

29.8k71633




29.8k71633












  • I have tested your code and it's not working, when I change it to If InStr(look_name, look_text) > 0 then is working correctly

    – 4est
    Mar 25 at 8:16











  • @4est it's "look_text" , you need to add the "

    – Shai Rado
    Mar 25 at 12:09











  • no, I need to use & to connect parameter, without this is not working

    – 4est
    Mar 25 at 13:13












  • @4est if you can give me the string you need to check trust me it will work. The Instr will give you the same result as using Like "*" & look_text & "*"

    – Shai Rado
    Mar 25 at 13:17











  • I have checked all possibility with string (at beginning, in the middle, at end) and it's not working, sorry

    – 4est
    Mar 25 at 18:18


















  • I have tested your code and it's not working, when I change it to If InStr(look_name, look_text) > 0 then is working correctly

    – 4est
    Mar 25 at 8:16











  • @4est it's "look_text" , you need to add the "

    – Shai Rado
    Mar 25 at 12:09











  • no, I need to use & to connect parameter, without this is not working

    – 4est
    Mar 25 at 13:13












  • @4est if you can give me the string you need to check trust me it will work. The Instr will give you the same result as using Like "*" & look_text & "*"

    – Shai Rado
    Mar 25 at 13:17











  • I have checked all possibility with string (at beginning, in the middle, at end) and it's not working, sorry

    – 4est
    Mar 25 at 18:18

















I have tested your code and it's not working, when I change it to If InStr(look_name, look_text) > 0 then is working correctly

– 4est
Mar 25 at 8:16





I have tested your code and it's not working, when I change it to If InStr(look_name, look_text) > 0 then is working correctly

– 4est
Mar 25 at 8:16













@4est it's "look_text" , you need to add the "

– Shai Rado
Mar 25 at 12:09





@4est it's "look_text" , you need to add the "

– Shai Rado
Mar 25 at 12:09













no, I need to use & to connect parameter, without this is not working

– 4est
Mar 25 at 13:13






no, I need to use & to connect parameter, without this is not working

– 4est
Mar 25 at 13:13














@4est if you can give me the string you need to check trust me it will work. The Instr will give you the same result as using Like "*" & look_text & "*"

– Shai Rado
Mar 25 at 13:17





@4est if you can give me the string you need to check trust me it will work. The Instr will give you the same result as using Like "*" & look_text & "*"

– Shai Rado
Mar 25 at 13:17













I have checked all possibility with string (at beginning, in the middle, at end) and it's not working, sorry

– 4est
Mar 25 at 18:18






I have checked all possibility with string (at beginning, in the middle, at end) and it's not working, sorry

– 4est
Mar 25 at 18:18














1














I managed to solve the issue by changing



If look_name Like "*look_text*" Then


to



If look_name Like "*" & look_text & "*" Then





share|improve this answer

























  • Thank you @Vadim for adjust answer

    – 4est
    Mar 24 at 20:47















1














I managed to solve the issue by changing



If look_name Like "*look_text*" Then


to



If look_name Like "*" & look_text & "*" Then





share|improve this answer

























  • Thank you @Vadim for adjust answer

    – 4est
    Mar 24 at 20:47













1












1








1







I managed to solve the issue by changing



If look_name Like "*look_text*" Then


to



If look_name Like "*" & look_text & "*" Then





share|improve this answer















I managed to solve the issue by changing



If look_name Like "*look_text*" Then


to



If look_name Like "*" & look_text & "*" Then






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 24 at 17:25









Vadim

7,99243645




7,99243645










answered Mar 24 at 16:54









4est4est

1,06341533




1,06341533












  • Thank you @Vadim for adjust answer

    – 4est
    Mar 24 at 20:47

















  • Thank you @Vadim for adjust answer

    – 4est
    Mar 24 at 20:47
















Thank you @Vadim for adjust answer

– 4est
Mar 24 at 20:47





Thank you @Vadim for adjust answer

– 4est
Mar 24 at 20:47

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55325948%2flooking-string-inside-cell-text-vb%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript