How to do automatic Web Queries??

G

Guest

Hi,

I would like to be able to import data automatically from a web page without
having to type in the web address.

I can create the correct url path in a cell using a CONCATENATE function but
cannot create a macro which references to that cell for the url look up.

This is the macro as it currently stands


With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.************************", _
Destination:=Range("a1"))
.Name = "main.php?cid=5516"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "2"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False

I would like this part ie With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.************************", _
Destination:=Range("a1"))
to use an url from a cell rather than a fixed link

Sorry if I have descibed this problem poorly.
 
P

pinmaster

Hi, I wanted to do excatly that a few months ago, so I was able to come
up with this:
connstring = Range("Sheet2!B2").Value
With ActiveSheet.QueryTables.Add(Connection:=connstring,

you will have to add "URL;" to your cell.

HTH
JG
 
G

Guest

Try something like this:

Dim URL2Use as String
URL2Use = "URL;" & Sheet1.Range("B11").Value

With ActiveSheet.QueryTables.Add(Connection:=URL2Use,
Destination:=Range("A1"))


Does that help?

***********
Regards,
Ron
 
G

Guest

Hi, yes that worked great, just needed a _ adding
ie
Dim URL2Use as String
URL2Use = "URL;" & Sheet1.Range("B11").Value

With ActiveSheet.QueryTables.Add(Connection:=URL2Use, _
Destination:=Range("A1"))

Thanks very much, am in your debt!!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top