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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
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,812
Messages
6,121,704
Members
449,048
Latest member
81jamesacct

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