Вы можете прочитать html из файла в MS HTML .HTMLDocument, используя ссылку на библиотеку объектов Microsoft HTML, а затем собрать список узлов всех строк. Предполагая, что в первой строке есть заголовки, затем l oop других строк и тестирование значения firstChild каждой строки.
Option Explicit
Public Sub test()
Dim html As MSHTML.HTMLDocument, firstColumnSecondRow As String, rows As Object, i As Long
Set html = GetHTMLFileContent("C:\Users\User\Desktop\test.html")
Set rows = html.querySelectorAll("tr")
Select Case rows.Length
Case 1
Debug.Print False
Exit Sub
Case 2
Debug.Print True
Case Is >= 3
firstColumnSecondRow = rows.item(1).firstChild.innerText
For i = 3 To rows.Length - 1
If rows.item(i).firstChild.innerText <> firstColumnSecondRow Then
Debug.Print False
Exit Sub
End If
Next
Debug.Print True
End Select
End Sub
Public Function GetHTMLFileContent(ByVal filePath As String) As MSHTML.HTMLDocument
'"C:\Users\User\Desktop\test.html"
Dim fso As Object, hFile As Object, hString As String, html As MSHTML.HTMLDocument
Set html = New MSHTML.HTMLDocument
Set fso = CreateObject("Scripting.FileSystemObject")
Set hFile = fso.OpenTextFile(filePath)
Do Until hFile.AtEndOfStream
hString = hFile.ReadAll()
Loop
html.body.innerHTML = hString
Set GetHTMLFileContent = html
End Function
Public Function GetHTMLFromFile(ByVal url As String) As String
Dim fso As Object, f As Object, outputString As String
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("C:\Users\HarrisQ\Desktop\HTML.txt", 1)
Do Until f.AtEndOfStream
outputString = f.ReadAll()
Loop
f.Close
GetHTMLFromFile = outputString
End Function
Если у вас уже есть строка, вы можете просто напрямую присвоить html документ с
Set html = New MSHTML.HTMLDocument
html.body.innerHTML = yourTableString ' no need for function call to read html and return HTMLDocument