Closed Thread
Results 1 to 21 of 21

Macro to check VAT Numeber

  1. #1
    Registered User
    Join Date
    06-27-2014
    Location
    Rome, Italy
    MS-Off Ver
    365
    Posts
    3

    Post Macro to check VAT Numeber

    Hello all,
    I'm quite sure you have a solution for the matter. I wanted to have an excel spreadsheet where I put in column A a list of VAT numbers. Executing the macro should give me in Column B if it is valid or not.

    This is quite beyond my ability in macros

    I found somenthings but it is not working, this is giving me an Object error:
    Please Login or Register  to view this content.

    I also found this string that seems very useful:
    http://vatid.eu/check/IT/12345678901
    It provides if the VAT is valid or not and the Name and Address, if given.
    It should be perceft to have those information on the sheet but I really don't know how to get those information.


    Other references are the WSDL from the Vies but I really don't know how to work on it.
    http://ec.europa.eu/taxation_customs...atService.wsdl

    Thanks for help

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Macro to check VAT Numeber

    hi angelooo, welcome to Excelforum, could you please provide Excel file with some VAT numbers to check?

  3. #3
    Registered User
    Join Date
    06-27-2014
    Location
    Rome, Italy
    MS-Off Ver
    365
    Posts
    3

    Re: Macro to check VAT Numeber

    Hi watersev,

    thanks for answer. Attaching you some random picked VATs, have not maked a file since yet.


    VAT
    Valid
    Name
    Street
    SE55600435480
    NL801865554B0
    GB681845796
    DE147330211
    IT03085140832
    FR54712035401


    Thanks

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro to check VAT Numeber

    Hi,

    Are you talking about Italian VAT numbers?
    If so we'd need to know the check digits algorithm.
    You may be able to use this UK algorithm and adapt it if Italy has a similar modulus (in this case 97) check.

    With your UK VAT number in A1
    enter the following as an array formula with Ctrl-Shift-Enter

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    If the VAT number is correct this will return the last 2 digits of the Vat number
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro to check VAT Numeber

    ..forgot to mention that the UK started to run out of VAT numbers in 2010.
    If the previous check fails then it might be in the new series. In which case the value 55 needs to be deducted from the modulus 97 result, (or if this makes it negative 44 should be added).

  6. #6
    Registered User
    Join Date
    06-27-2014
    Location
    Rome, Italy
    MS-Off Ver
    365
    Posts
    3

    Re: Macro to check VAT Numeber

    Hi Richard,

    thanks for reply. I'm talking about all countries VAT. DE-IT-FR-FI-etc.
    I should not check the algorithm but I should check the VAT on a webservice like VIES or other services like that.

    Regards

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro to check VAT Numeber

    In that case you'll need to be able to link to a web site that contains a vat # checker for various countries and somehow feed the site with a number and retrieve the result in Excel. This is all non trivial stuff and I'm by no means sure it's going to be possible and certainly not easily. But I'll be extremely interested to see what other answers are forthcoming.

  8. #8
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Macro to check VAT Numeber

    hi angelooo, please check attachment

    Sheet "Function": UDF function VAT is used
    Sheet "Code": press Run button to use code
    Attached Files Attached Files

  9. #9
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro to check VAT Numeber

    Well done watersev.

    A simple solution, much against my expectations.

  10. #10
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Macro to check VAT Numeber

    @watersev

    I like that solution, great job.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  11. #11
    Registered User
    Join Date
    10-30-2014
    Location
    budapest
    MS-Off Ver
    2010
    Posts
    1

    Re: Macro to check VAT Numeber

    Excellent job!

  12. #12
    Registered User
    Join Date
    12-12-2015
    Location
    Frankfurt
    MS-Off Ver
    2007
    Posts
    2

    Re: Macro to check VAT Numeber

    Mega! THXX!!
    How can we get also the VIES "Abfrage-Nummer", beside VAT ID etc. into the check???

  13. #13
    Registered User
    Join Date
    12-12-2015
    Location
    Frankfurt
    MS-Off Ver
    2007
    Posts
    2

    Re: Macro to check VAT Numeber

    One more Thing. Where do I know that there is no Virus in this Makro ? (( Do you thing it is safe? Since I have upload it sometimes my Computer goes down. I made a Virus check, but no Virus was found.

  14. #14
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro to check VAT Numeber

    Hi and welcome to the forum. Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

  15. #15
    Registered User
    Join Date
    06-09-2016
    Location
    Budapest
    MS-Off Ver
    2010
    Posts
    1

    Re: Macro to check VAT Numeber

    Hi All,

    I tested watersev's attached xlsm file; but I it does not give always correct check-values.
    For example:

    HU13030423 >> macro drops INACTIVE
    >> VIES(http://ec.europa.eu/taxation_customs/vies/) drops ACTIVE

    Would someone so kind to check this issue? For me will be very important to get exact check values.
    Thanks in advance!

  16. #16
    Registered User
    Join Date
    01-10-2015
    Location
    Central Europe
    MS-Off Ver
    2016
    Posts
    5

    Re: Macro to check VAT Numeber

    Hi,

    Tested the code and seems to working fine. Just make sure you added the right libraries to your excel. Watersev referenced MSXML wich is optional and needs to be added.

  17. #17
    Registered User
    Join Date
    08-23-2019
    Location
    Poland
    MS-Off Ver
    Office 2007,2013
    Posts
    1

    Re: Macro to check VAT Numeber

    Good Day,

    I am replying to this thread as I have relevant issue
    1) EU has changed VIES website
    The correct one now is *...*taxation_customs/vies/

    2) If I use code from other site

    [I]#If VBA7 Then
    Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal milliseconds As LongPtr) 'MS Office 64 Bit
    #Else
    Public Declare Sub Sleep Lib "kernel32" (ByVal milliseconds As Long) 'MS Office 32 Bit
    #End If

    Option Explicit

    Public Sub VIES2()
    Application.ScreenUpdating = False
    Dim IE As Object

    'Uruchomienie Internet Explorera i wstrzymanie dalszej akcji az uzyska stan gotowosci
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = False
    IE.navigate "VIES website"
    Do While IE.ReadyState <> 4: DoEvents: Loop

    'Wypelnienie formularza odpowiednimi wartosciami i klikniecie przycisku sprawdzenia
    IE.document.getElementById("countryCombobox").Value = "IT"
    IE.document.getElementById("number").Value = "01802840023"
    IE.document.getElementById("requesterCountryCombobox").Value = "PL"
    IE.document.getElementById("requesterNumber").Value = "5242617178"
    IE.document.getElementById("submit").Click

    sleep (5000) 'or increase to 10000
    Dim tbl As Object

    Set tbl = IE.document.getElementById("vatResponseFormTable")

    Dim ws As Worksheet
    Set ws = ActiveWorkbook.Worksheets.Add
    ws.Name = "Results"
    Dim rng As Range, currentRow As Object, currentColumn As Object, i As Long, outputRow As Long

    outputRow = outputRow + 1
    Set rng = ws.Range("B" & outputRow)

    For Each currentRow In tbl.Rows
    For Each currentColumn In currentRow.Cells
    rng.Value = currentColumn.outerText
    Set rng = rng.Offset(, 1)
    i = i + 1
    Next currentColumn

    outputRow = outputRow + 1
    Set rng = rng.Offset(1, -i)
    i = 0
    Next currentRow
    Application.ScreenUpdating = True
    End Sub

    I would get the following table with info

    Tak, numer VAT aktywny [Yes number is valid]

    Państwo Członkowskie IT
    Numer VAT IT 01802840023
    Data zapytania 2019-08-29 08:56
    Nazwa FINAGRIT SRL
    Adres "VIA MONTE DI PIETA' N 36
    13100 VERCELLI VC"
    Identyfikator zapytania WAPIAAAAWzcKas_a

    As I have thousand of numbers to be checked on a weekly basis I cannot handle response formatted by default.
    In order to make sense I need to move some info from columns to rows etc.

    What I am trying to achieve is below so to move:
    1st item in row to the last column instead(so "F")
    2nd item in row to the first column "A"
    3rd item in row to column "B"
    4rd item in row to column "C"
    5th item in row to column "D"
    6th item in row to column "E"


    Państwo Członkowskie Numer VAT Data zapytania Nazwa Adres Identyfikator
    IT IT 01802840023 2019-08-29 08:56 FINAGRIT SRL "VIA MONTE DI PIETA' N 36 13100 VERCELLI VC" WzcKas_a


    Status
    Tak, numer VAT aktywny


    1)How can I transpose the response from VIES site from rows to columns and change sequence ?
    2) Once this is done how can I instead of "hardcoded"
    client number i.e.
    IE.document.getElementById("countryCombobox").Value = "IT"
    IE.document.getElementById("number").Value = "01802840023"

    input subsequent number from 2 columns in Excel - 1st with country code, second with number to be checked and loop until there is no more data in Excel in those columns ("A" and "B"?)

    LM

  18. #18
    Registered User
    Join Date
    01-22-2020
    Location
    Spain
    MS-Off Ver
    Windows 10
    Posts
    2

    Re: Macro to check VAT Numeber

    Hello. Can someone update this code??? Im trying to do it but gives some nerd errors.

    Help would be appreciate!!

  19. #19
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,453

    Re: Macro to check VAT Numeber

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread

  20. #20
    Registered User
    Join Date
    07-05-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    4

    Re: Macro to check VAT Numeber

    Hi Guys,

    I am new here and was trying to use macro of Watersev. Unfortunately it gives me an error:runtime error, access denied... Anybody know why? I have around 3k VAT IDs to validate and was thinking that macro would be the best solution in this case...

  21. #21
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro to check VAT Numeber

    Please read post #19 from 18 months ago. It is still relevant.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Adjust a macro to check for content of a cell and then run a macro on target sheet
    By dreddster in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-17-2013, 04:37 AM
  2. Automatically check one or more check boxes when a parent check box is manually checked
    By Steverizer in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-28-2013, 01:56 PM
  3. Macro to force format and check barcode check digit
    By Code Flunkie in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-02-2009, 10:27 AM
  4. Macro to check for blank cell entry, copy previous value, and check for duplicates
    By xPunxNotDeadx in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-26-2009, 06:33 PM
  5. Macro to check range, if false check another range until true, then copy
    By jayers in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-12-2009, 04:19 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1