ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   help with prompt to pull wed address (https://www.excelbanter.com/excel-programming/430575-help-prompt-pull-wed-address.html)

Bobbo

help with prompt to pull wed address
 

I am trying to use a macro that will prompt for a web address then store that
address in a querytable. What I have so far is below. The prompt works but It
errors out when you select OK on the inputbox. If I comment out myRange and
just hardcode the address it will work. Any suggestions

Thanks
Bob
Set myRange = Application.InputBox(prompt:="Web Address", Type:=2)
With ActiveSheet.QueryTables.Add(Connection:=myRange,
Destination:=Range("$A$1"))
.Name = _
""
.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 = "68"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With

Bernie Deitrick

help with prompt to pull wed address
 
Bobbo,

Your myRange appears to be a range object. You cannot set the range object to be a string value,
but you could set the myRange object's value to be the string.

This is how you could work with it:

Dim myRange As Range
Set myRange = ActiveCell
myRange.Value = Application.InputBox(prompt:="Web Address", Type:=2)

thought there is no clue as to which cell you want to be myRange....

HTH,
Bernie
MS Excel MVP


"Bobbo" wrote in message
...
I am trying to use a macro that will prompt for a web address then store that
address in a querytable. What I have so far is below. The prompt works but It
errors out when you select OK on the inputbox. If I comment out myRange and
just hardcode the address it will work. Any suggestions

Thanks
Bob
Set myRange = Application.InputBox(prompt:="Web Address", Type:=2)
With ActiveSheet.QueryTables.Add(Connection:=myRange,
Destination:=Range("$A$1"))
.Name = _
""
.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 = "68"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With





All times are GMT +1. The time now is 10:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com