ezequiel_g
New Member
- Joined
- Jul 22, 2013
- Messages
- 1
Hi, I'm having this problem: i have a list or URLs on a sheet, and i want a macro that import a table (always the table 2) from the URL contained in the selected cell. When I record the macro, it doesn't store 'the selected cell' as the place where it gets the information about where to obtain the data, it stores its content as constant.
Here is the code:
ActiveWorkbook.Worksheets.Add
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.minagri.gob.ar/new/0-0/programas/dma/compras_ventas_embarques/2013/01_embarque_2013-01-02.php" _
, Destination:=Range("$A$1"))
.Name = "01_embarque_2013-01-02"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.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
End With
What i show in bold is where it should be a reference of the selected cell where i execute the macro.
Thanks for your time,
Ezequiel
Here is the code:
ActiveWorkbook.Worksheets.Add
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.minagri.gob.ar/new/0-0/programas/dma/compras_ventas_embarques/2013/01_embarque_2013-01-02.php" _
, Destination:=Range("$A$1"))
.Name = "01_embarque_2013-01-02"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.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
End With
What i show in bold is where it should be a reference of the selected cell where i execute the macro.
Thanks for your time,
Ezequiel