I call the function PopData(written below) from any sheet by saying =popData(P1,P2,P3,P4). To get the user name and password from the web server(using http) I call Proc URLGet(written below). My problms are
1) When procedure URLGet is called from PopData then after executing line ".Refresh BackgroundQuery:=False(in URLGet)" the control comes back to start of the PopData and URLGet gets called up again.
2)I get run-time error "Application-defined or object-defined error" at line ActiveSheet.Range("z100".Value = ""
Pls help.....Code is written below....
Function PopData(PRange1 As Range, Optional PRange2 As Range, Optional rank_algorithm As String, Optional return_single_triple As Integer) As Boolean
PopData = False
Dim gUser_Id
Dim gPWD
URLGet (" Dim cellVal
cellVal = ActiveSheet.Range("z100".Value
Dim pos
pos = InStr(1, cellVal, ","
gUser_Id = Mid(cellVal, 1, pos - 1)
gPWD = Mid(cellVal, pos + 1)
ActiveSheet.Range("z100".Value = ""
PopData = False
End Function
Sub URLGet(ByVal url As String)
On Error Resume Next
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;" & url, _
Destination:=Range("z100")
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
1) When procedure URLGet is called from PopData then after executing line ".Refresh BackgroundQuery:=False(in URLGet)" the control comes back to start of the PopData and URLGet gets called up again.
2)I get run-time error "Application-defined or object-defined error" at line ActiveSheet.Range("z100".Value = ""
Pls help.....Code is written below....
Function PopData(PRange1 As Range, Optional PRange2 As Range, Optional rank_algorithm As String, Optional return_single_triple As Integer) As Boolean
PopData = False
Dim gUser_Id
Dim gPWD
URLGet (" Dim cellVal
cellVal = ActiveSheet.Range("z100".Value
Dim pos
pos = InStr(1, cellVal, ","
gUser_Id = Mid(cellVal, 1, pos - 1)
gPWD = Mid(cellVal, pos + 1)
ActiveSheet.Range("z100".Value = ""
PopData = False
End Function
Sub URLGet(ByVal url As String)
On Error Resume Next
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;" & url, _
Destination:=Range("z100")
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub