neilsolaris
New Member
- Joined
- Feb 5, 2015
- Messages
- 7
Hello,
I wrote some VBA code a a while ago, which checks which VAT registered musicians on my database, if any, have deregistered. Unfortunately I used a European VAT checking website before, and because I'm based in the UK and since we've left the EU recently, it no longer works. Therefore, I have changed it to VAT checking website to a British one. However, I'm getting stuck with some coding. On the first page, I need to enter the VAT number from my Excel file to the search box, and then submit it. Both these lines are not working yet. Is someone able to help show me what I'm doing wrong? Many thanks for your help.
I haven't updated the second part of my code yet (i.e. the next page where it shows if they are VAT registered or not). I'm sure I'll need some help with that too, but I'll see if I can solve the first part first.
Sub CheckVatPlayers()
Dim x As Integer, y As Integer, z As String, objIE As InternetExplorer, aEle As HTMLLinkElement, findtext As String, player As String
x = 2
Set objIE = New InternetExplorer
objIE.Visible = True
Do Until Cells(x, 1) = ""
If Left(Cells(x, 4), 2) <> "GB" Then
Cells(x, 4) = "GB" & Replace(Cells(x, 4), " ", "")
End If
objIE.Navigate "https://www.tax.service.gov.uk/check-vat-number/enter-vat-details"
Do While objIE.Busy = True Or objIE.ReadyState <> 4: DoEvents: Loop
Application.Wait Now + #12:00:01 AM#
objIE.Document.getElementsById("target").Value = Cells(x, 4)
objIE.Document.getElementsById("target")(0).Click
Do While objIE.Busy = True Or objIE.ReadyState <> 4: DoEvents: Loop
Application.Wait Now + #12:00:01 AM#
y = 2
For Each aEle In objIE.Document.getElementsByClassName("vat_number_h1")
Debug.Print aEle.innerText
z = Trim(aEle.innerText)
Cells(x, 7) = z
If Left(z, 1) = "V" Then
Cells(x, 7).Font.Color = vbBlack
Else: Cells(x, 7).Font.Color = vbRed
End If
With Cells(x, 6)
.Value = Date
.NumberFormat = "dd/mm/yyyy"
End With
y = y + 1
Next
x = x + 1
Loop
End Sub
I wrote some VBA code a a while ago, which checks which VAT registered musicians on my database, if any, have deregistered. Unfortunately I used a European VAT checking website before, and because I'm based in the UK and since we've left the EU recently, it no longer works. Therefore, I have changed it to VAT checking website to a British one. However, I'm getting stuck with some coding. On the first page, I need to enter the VAT number from my Excel file to the search box, and then submit it. Both these lines are not working yet. Is someone able to help show me what I'm doing wrong? Many thanks for your help.
I haven't updated the second part of my code yet (i.e. the next page where it shows if they are VAT registered or not). I'm sure I'll need some help with that too, but I'll see if I can solve the first part first.
Sub CheckVatPlayers()
Dim x As Integer, y As Integer, z As String, objIE As InternetExplorer, aEle As HTMLLinkElement, findtext As String, player As String
x = 2
Set objIE = New InternetExplorer
objIE.Visible = True
Do Until Cells(x, 1) = ""
If Left(Cells(x, 4), 2) <> "GB" Then
Cells(x, 4) = "GB" & Replace(Cells(x, 4), " ", "")
End If
objIE.Navigate "https://www.tax.service.gov.uk/check-vat-number/enter-vat-details"
Do While objIE.Busy = True Or objIE.ReadyState <> 4: DoEvents: Loop
Application.Wait Now + #12:00:01 AM#
objIE.Document.getElementsById("target").Value = Cells(x, 4)
objIE.Document.getElementsById("target")(0).Click
Do While objIE.Busy = True Or objIE.ReadyState <> 4: DoEvents: Loop
Application.Wait Now + #12:00:01 AM#
y = 2
For Each aEle In objIE.Document.getElementsByClassName("vat_number_h1")
Debug.Print aEle.innerText
z = Trim(aEle.innerText)
Cells(x, 7) = z
If Left(z, 1) = "V" Then
Cells(x, 7).Font.Color = vbBlack
Else: Cells(x, 7).Font.Color = vbRed
End If
With Cells(x, 6)
.Value = Date
.NumberFormat = "dd/mm/yyyy"
End With
y = y + 1
Next
x = x + 1
Loop
End Sub