In the following snippet of code I am setting the variable iTotalScore to a value from a website. If the value in the website doesn't exist I get a type mismatch, otherwise I get an integer which I store in my CBSImport sheet. Because I'm resuming next on error, when there is a type mismatch the iTotalScore integer remains the same from the prior loop. Instead, I'd like to set it to zero. I tried to do if(iserror(iTotalScore =.FindElementByXPath("/html/body/div[1]/div[4]/div//div[2]/div/input").Value) then iTotalScore = 0 else... But for some reason it doesn't catch it as an error there, it continues to the else and then errors out there as a type mismatch.
What I'd like to do is if there is a type mismatch then set iTotalScore to zero, store that in CBSImport and continue to the next iNameCount. Any suggestions?
For iNameCount = 1 To 8
iTotalScore = .FindElementByXPath("/html/body/div[1]/div[4]/div//div[2]/div/input").Value
On Error Resume Next
Sheets("CBSImport").Range("B" & iNameCount + 1) = iTotalScore
Next iNameCount
What I'd like to do is if there is a type mismatch then set iTotalScore to zero, store that in CBSImport and continue to the next iNameCount. Any suggestions?
For iNameCount = 1 To 8
iTotalScore = .FindElementByXPath("/html/body/div[1]/div[4]/div//div[2]/div/input").Value
On Error Resume Next
Sheets("CBSImport").Range("B" & iNameCount + 1) = iTotalScore
Next iNameCount