If function when specific text contains in element

sudarshank2

New Member
Joined
Nov 1, 2015
Messages
12
I have a multiple elements they are as below

ws.Cells(rw, 5) = .getElementsByTagName("tr").Item(2).innerText
ws.Cells(rw, 5) = .getElementsByTagName("tr").Item(3).innerText
ws.Cells(rw, 5) = .getElementsByTagName("tr").Item(4).innerText

And so on...

If in these elements if any line contains "ABC" or "ASD" or "QWE" or "WER" (just an imaginary text given) then it has to update the data in ws.Cells(rw,5)

Can somebody please help me :'(
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
I don't know what I'm doing but I'm guessing something like...
myText = ws.Cells(rw, 5).getElementsByTagName("tr").Item(2).innerText
If myText = "ABC" Or myText = "ASD" Or myText = "QWE" Or myText = "WER" Then
'Update the data
End If

I just wrote Update the data on the code because I don't know how you want it updated. Like what is suppose to happen?
 
Upvote 0
Thank you for your reply.

I'll rephrase my question:

I have a specific work as "ABC"

I have list of tag name(element) as mentioned below. If any tag name contains "ABC" then place the value in ws.Cells(rw,5) or else nothing.
Tag Names:-
ws.Cells(rw, 5) = .getElementsByTagName("tr").Item(2).innerText

ws.Cells(rw, 5) = .getElementsByTagName("tr").Item(3).innerText
ws.Cells(rw, 5) = .getElementsByTagName("tr").Item(4).innerText

Note: You have mentioned as "=" but I need it as if "ABC" word contains(not the text like "A" you can find one place and "B" another). ABC should be together as ABC or ABCDE or XYZABCDR
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,984
Messages
6,122,601
Members
449,089
Latest member
Motoracer88

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