Get country name from a range of IP number with google sheets script and paste the result in another column

Viewed 230

In my Google spreadsheet, in column H I have a list of IP numbers. What I need to a script what will take those numbers and fetch the Country name. I need this to be script since the spreadsheet gets populated from a web-form. What I have is a formula that does that perfectly but I have to copy the formula manually with each form submission. Since I get lots of submissions per day, it's tedious to do this manually. I need the script to run on spreadsheet update. The formula I have is this:

=query( importhtml("http://whatismyipaddress.com/ip/" & H1526, "table", 2), "select Col2 where Col1 = 'Country:' ", 0 ) 

The last populated row is H1526. I tried the "ARRAYFORMULA" but no array formulas seems to work with my query function. The column where I have the IPs is H and I need the country name in column I.

1 Answers
Related