Hello everyone,
I’m layperson in VBA coding. Would be grateful for any help.
I have a code as it follows below.
It has list of stock symbols (1 to 6 letters each) in the column K
It loops through each cell in column K and returns value to cell B4
Then it calls macro GetYahooData to download historical price data (of the stock symbol in cell B4) into the range of cells and copies these data.
I want to modify code so that it could find CSV file in the folder C:\VBA and open it.
The file name corresponds to current stock symbol in Worksheets("Sheet2").Range("B4").Value
So if, for example, current value of cell B4 is AAPL the file name will be AAPL.csv
It is important that if stock symbol is just A it should not open every file containing A in its name.
The aim is to paste copied historical price data of each stock into corresponding file.
The rest of the code modification I hope I will manage myself.
Also asked here Find file in the folder. Name of the file equal to cell text value - OzGrid Free Excel/VBA Help Forum
I’m layperson in VBA coding. Would be grateful for any help.
I have a code as it follows below.
VBA Code:
Sub GetPrice()
Dim ws As Worksheet
Dim cell As Range
For Each cell In Range("K1:K100")
If cell.Value <> "" Then
Worksheets("Sheet2").Range("B4").Value = cell.Value
Call GetYahooDataFromJSON
End If
Next cell
End Sub
It has list of stock symbols (1 to 6 letters each) in the column K
It loops through each cell in column K and returns value to cell B4
Then it calls macro GetYahooData to download historical price data (of the stock symbol in cell B4) into the range of cells and copies these data.
I want to modify code so that it could find CSV file in the folder C:\VBA and open it.
The file name corresponds to current stock symbol in Worksheets("Sheet2").Range("B4").Value
So if, for example, current value of cell B4 is AAPL the file name will be AAPL.csv
It is important that if stock symbol is just A it should not open every file containing A in its name.
The aim is to paste copied historical price data of each stock into corresponding file.
The rest of the code modification I hope I will manage myself.
Also asked here Find file in the folder. Name of the file equal to cell text value - OzGrid Free Excel/VBA Help Forum
Last edited by a moderator: