I am trying to call a sub routine in another sub routine and want to return some values. However it doesn't seem to return any value. How would I write this as a function ? The code is the following:
Sub tickersymbolchange()
Dim RSTA_ISIN, RSTA_Currency, RSTA_Ticker As String
For Each rng In r
ticker_wo_equity = Replace(rng.Value, " Equity", "")
Exchangecode = Right(ticker_wo_equity, 2)
Select Case Exchangecode
Case "PO", "L3", "B3", "S2", "TQ", "SS"
'MsgBox "I am in PO"
Call getRSTA_POL3B3S2TQSSIXEB(ticker_wo_equity, RSTA_ISIN, RSTA_Currency, RSTA_Ticker)
'Get ISIN from Rsta
If IsEmpty(RSTA_ISIN) Then
rng.Offset(0, 11) = "N/A"
Else
rng.Offset(0, 11) = RSTA_ISIN
End If
'Get Currency from Rsta
If IsEmpty(RSTA_Currency) Then
rng.Offset(0, 12) = "N/A"
Else
rng.Offset(0, 12) = RSTA_Currency
End If
End select
End Sub
Sub getRSTA_POL3B3S2TQSSIXEB(ticker, Optional ByVal getISIN As String, Optional ByVal getCurrency As String, Optional ByVal getTicker As String, Optional ByVal getUS As String, Optional ByVal getTickerTicker_IBEX As String, Optional ByVal getPriceCode_GR As String)
BBs.Send ticker & "<Equity> RSTA"
BBs.Go
'Application.Wait (Now + TimeValue("0:00:01"))
'Sleep 1000
BBs.CopyScreen
getISIN = BBs.GetTextField(7, 2, 13)
getCurrency = BBs.GetTextField(7, 15, 4)
getTicker = BBs.GetTextField(7, 20, 6)
getUS = BBs.GetTextField(7, 11, 9)
getTickerTicker_IBEX = BBs.GetTextField(7, 2, 7)
getPriceCode_GR = BBs.GetTextField(7, 2, 7)
End Sub
So here I am trying to give RSTA_ISIN to the function getRSTA_POL... and then the function should assign RSTA_ISIN the value of getISIN, however RSTA_ISIN and all the other parameters are always empty.
byRef, notbyVal. After you've changed the values and fallen out of the sub the original vars passed in will hold the new values.