I am trying to develop vba code in a destination workbook, test.xlsm, which has separate worksheets for a number of ticker symbols, about 100 in all, to update, i.e. copy & paste downloaded financial data, (1) closing price vs. time for each ticker symbol, and (2) dividend yield vs time, for each ticker symbol.
My attempted workbook, test.xlsm, needs to copy/paste column A3 to the last non blank row of A, and column E3 to the last non blank row of E in workbook, Multiple Stock Quote Downloader.xlsm, closed on my computer NAS drive Y, to colums M:N, starting at M7:N7, on the active worksheet for the ticker symbol which is named in cell N2 on the active worksheet in workbook, test.xlsm. So the full address for workbook, Multiple Stock Quote Downloader.xlsm, would be Y://public/investments/Distribution History/Multiple Stock Quote Downloader.xlsm. The vba code needs to get the name of the worksheet in Multiple Stock Quote Downloader.xlsm, from cell N2 in workbook, text.xlsm, on the active sheet whose name is the content of cell N2.
Next the vba code needs to update, i.e. copy and paste, dividend yield vs time data, in workbook Bulk Dividend Downloader,xlsm in the folder Y://public/investments/Distribution History/, on the worksheet specified in cell N2 of test.xlsm, the dividend vs. date data is in columns A:B, starting at row A3:B3 to the last non blank row, for the ticker symbol specified in cell N2 of the N2 worksheet in test.xlsm.
Here is what I have so far but it is not generic but hard coded for only a specific worksheet, identified in N2, in workbook, test.xlsm. Can someone tell me how to make this generic?
My attempted workbook, test.xlsm, needs to copy/paste column A3 to the last non blank row of A, and column E3 to the last non blank row of E in workbook, Multiple Stock Quote Downloader.xlsm, closed on my computer NAS drive Y, to colums M:N, starting at M7:N7, on the active worksheet for the ticker symbol which is named in cell N2 on the active worksheet in workbook, test.xlsm. So the full address for workbook, Multiple Stock Quote Downloader.xlsm, would be Y://public/investments/Distribution History/Multiple Stock Quote Downloader.xlsm. The vba code needs to get the name of the worksheet in Multiple Stock Quote Downloader.xlsm, from cell N2 in workbook, text.xlsm, on the active sheet whose name is the content of cell N2.
Next the vba code needs to update, i.e. copy and paste, dividend yield vs time data, in workbook Bulk Dividend Downloader,xlsm in the folder Y://public/investments/Distribution History/, on the worksheet specified in cell N2 of test.xlsm, the dividend vs. date data is in columns A:B, starting at row A3:B3 to the last non blank row, for the ticker symbol specified in cell N2 of the N2 worksheet in test.xlsm.
Here is what I have so far but it is not generic but hard coded for only a specific worksheet, identified in N2, in workbook, test.xlsm. Can someone tell me how to make this generic?
Code:
Sub UpdateHistoricalDividends2()
'
' UpdateHistoricalDividends2 Macro
'
'
Windows("Bulk Dividend Downloader.xlsm").Activate
Sheets("ARTOX").Select
Range("A3:B3").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("test.xlsm").Activate
Range("P7").Select
ActiveSheet.Paste
End Sub
Sub UpdateHistoricClosePrice2()
'
' UpdateHistoricClosePrice2 Macro
'
'
Windows("Multiple Stock Quote Downloader.xlsm").Activate
Sheets("ARTOX").Select
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWindow.ScrollRow = 3660
ActiveWindow.ScrollRow = 3653
ActiveWindow.ScrollRow = 3645
ActiveWindow.ScrollRow = 3631
ActiveWindow.ScrollRow = 3601
ActiveWindow.ScrollRow = 3587
ActiveWindow.ScrollRow = 3506
ActiveWindow.ScrollRow = 3462
ActiveWindow.ScrollRow = 3190
ActiveWindow.ScrollRow = 3131
ActiveWindow.ScrollRow = 2830
ActiveWindow.ScrollRow = 2764
ActiveWindow.ScrollRow = 2609
ActiveWindow.ScrollRow = 2558
ActiveWindow.ScrollRow = 2433
ActiveWindow.ScrollRow = 2381
ActiveWindow.ScrollRow = 2271
ActiveWindow.ScrollRow = 2198
ActiveWindow.ScrollRow = 2043
ActiveWindow.ScrollRow = 1977
ActiveWindow.ScrollRow = 1874
ActiveWindow.ScrollRow = 1735
ActiveWindow.ScrollRow = 1580
ActiveWindow.ScrollRow = 1500
ActiveWindow.ScrollRow = 1411
ActiveWindow.ScrollRow = 1257
ActiveWindow.ScrollRow = 1176
ActiveWindow.ScrollRow = 1095
ActiveWindow.ScrollRow = 1037
ActiveWindow.ScrollRow = 912
ActiveWindow.ScrollRow = 860
ActiveWindow.ScrollRow = 772
ActiveWindow.ScrollRow = 721
ActiveWindow.ScrollRow = 662
ActiveWindow.ScrollRow = 610
ActiveWindow.ScrollRow = 552
ActiveWindow.ScrollRow = 493
ActiveWindow.ScrollRow = 456
ActiveWindow.ScrollRow = 419
ActiveWindow.ScrollRow = 339
ActiveWindow.ScrollRow = 316
ActiveWindow.ScrollRow = 258
ActiveWindow.ScrollRow = 236
ActiveWindow.ScrollRow = 199
ActiveWindow.ScrollRow = 170
ActiveWindow.ScrollRow = 81
ActiveWindow.ScrollRow = 59
ActiveWindow.ScrollRow = 37
ActiveWindow.ScrollRow = 8
ActiveWindow.ScrollRow = 1
Range("A2:A3685,E2").Select
Range("E2").Activate
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("test.xlsm").Activate
Range("M6").Select
ActiveSheet.Paste
End Sub
Last edited by a moderator: