help with prompt to pull wed address

B

Bobbo

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
 
B

Bernie Deitrick

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
 

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