Converting Excel with Macros to Google Spreadsheets
One of my recent project involved converting a finance related Microsoft Excel Spreadsheet into a web based Google Spreadsheet that can be accessed from a web browser. The Excel sheet had VBA Macros that were converted into corresponding functions using Google Apps Scripts.
The StatusBar property of the Application object in Excel VBA displays the macro progress in the Excel UI and you can replace it with the .toast() method of SpreadsheetApp class in Google Scripts.
Function GetFundName(symbol As String) As String Dim Inet1 'As Inet Dim fndSym As Integer, endCnt As Integer, begCnt As Integer Dim bFound As Boolean Application.StatusBar = "Getting Fund Name for " & symbol Set Inet1 = CreateObject("Microsoft.XMLHTTP") sStockPage = "http://finance.yahoo.com/q/hp?s=" & symbol With Inet1 .Open "GET", sStockPage, False .send sStockPage = Inet1.ResponseText End With Set Inet1 = Nothing fndSym = InStrRev(sStockPage, "(" & symbol) // .indexOf in JS endCnt = fndSym - 2 bFound = False Do Until bFound fndSym = fndSym - 1 'Debug.Print (Mid(sStockPage, fndSym, 1)) // Logger.log in Google Scripts bFound = (Mid(sStockPage, fndSym, 1) = ">") Loop GetFundName = Mid(sStockPage, fndSym + 1, endCnt - fndSym + 1) // .substring() in JS Application.StatusBar = False End Function
Google Developer Expert, Google Cloud Champion
Amit Agarwal is a Google Developer Expert in Google Workspace and Google Apps Script. He holds an engineering degree in Computer Science (I.I.T.) and is the first professional blogger in India.
Amit has developed several popular Google add-ons including Mail Merge for Gmail and Document Studio. Read more on Lifehacker and YourStory