La consultazione del forum è libera per tutti.
Per poter porre un quesito è invece necessario essere un utente registrato (clicca qui se non lo sei).
Tutti gli utenti che richiedono un supporto, come da REGOLAMENTO, sono caldamente invitati ad allegare un file di esempio con l'indicazione di quello che si desidera ottenere.
Buongiorno a tutti,
Vorrei sapere se c'è il modo di velocizzare il calcolo di questa funzione.
Ho un foglio con un centinaio di celle contenenti la formula Yahoo per il recupero delle quotazioni di alcuni titoli azionari. Il ricalcolo del foglio ci mette molto tempo. È possibile modificarlo per accorciare i tempi? GRAZIE
Function Yahoo(Symbol As String, SearchParameter As String) ' Get near real-time stock quote from Yahoo via JSON query Dim URL As String, response As String, stripped As String, inbits() As String, i As Long, Info As String Dim request As WinHttp.WinHttpRequest ' needs Tools|References|WinHTTP Services On Error GoTo Err Select Case SearchParameter Case Is = "Quote" Info = "regularMarketPrice:" Case Is = "SName" Info = "shortName:" Case Is = "LName" Info = "longName:" Case Is = "Date" Info = "regularMarketTime:" Case Is = "PClose" Info = "regularMarketPreviousClose:" Case Is = "Open" Info = "regularMarketOpen:" Case Is = "DHigh" Info = "regularMarketDayHigh:" Case Is = "DLow" Info = "regularMarketDayLow:" Case Else: Info = SearchParameter End Select URL = "https://query2.finance.yahoo.com/v7/finance/options/" & Trim(Symbol) Set request = New WinHttp.WinHttpRequest With request .Open "GET", URL, True .SetRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8" .Send .WaitForResponse response = .responseText End With If InStr(response, """result"":[]") <> 0 Then GoTo Err1 ' ticker not found 'kludge parse: strip JSON delimiters and quotes stripped = Replace(Replace(Replace(Replace(Replace(response, "[", ""), "]", ""), "{", ""), "}", ""), """", "") stripped = Replace(stripped, ":", ":,") ' keep colons for readability, but make them delimit inbits = split(stripped, ",") ' split i = LBound(inbits) Do While inbits(i) <> Info And i <= UBound(inbits) ' find "regularMarketPrice:" tag i = i + 1 Loop If i > UBound(inbits) Then GoTo Err ' not found If IsNumeric(inbits(i + 1)) Then Yahoo = Val(inbits(i + 1)) Else: Yahoo = Trim(inbits(i + 1)) Exit Function Err: Yahoo = CVErr(xlErrNA) Err1: Yahoo = "Codice Errato" End Function
nessun aiutino?