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

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현