JohnSawers
New Member
- Joined
- Dec 14, 2012
- Messages
- 4
<tbody>
[TD="class: votecell"][/TD]
[TD="class: postcell"] I have a series of macros (MySQL selections) to pull data into and out of a workbook when I select a stock ticker from a drop down menu. On an individual basis this works fine. I am trying to automate this with a loop macro, but without success. In my current code below, I am trying to loop thru a list of stock ticker symbols (from column "A2"), then assign the next value in that list to the named cell called "stock_ticker". The stock identifier in this named cell ""stock_ticker" is used by the "MySQL_Get_data1-8" macros to identify the correct stock information to download, so the loop ought then to process a new stock as it runs down the list until the end. So much for theory however!
HTML:
Start code here:
Sub Loop_data1()
' start of list of stock tickers Range("A2").Select 'Set Do loop to stop when an empty cell is reached Do Until IsEmpty(ActiveCell) 'Code inserted here Dim stock_ticker As String ' "stock_ticker" is a named cell on sheet that I want changed with the loop stock_ticker = Range("stock_ticker") ' to change value of this named cell to the next Range("Stock_ticker") = ActiveCell.Value ' name of macros I want run with the new stock_ticker value MySQL_Get_data1 MySQL_Get_data2 MySQL_Get_data3 MySQL_Get_data4 MySQL_Get_data5 MySQL_Get_data6 MySQL_Get_data17 clickcmd 'Step down 1 row from present location ActiveCell.Offset(1, 0).Select Loop
End Sub
the macro appears to run some of the macros but does not loop thru the different stock_tickers in the list. I have tried putting below the code above the "Do until .. line, but still with no success:
HTML:
Dim stock_ticker As String stock_ticker = Range("stock_ticker") Range("Stock_ticker") = ActiveCell.Value
[/TD]
</tbody>