Loop thru range to select value for named cell and then run a series of macros until the end of the list

JohnSawers

New Member
Joined
Dec 14, 2012
Messages
4
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
End code here



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
Can anyone please help?


<tbody>
</tbody>
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,214,782
Messages
6,121,532
Members
449,037
Latest member
tmmotairi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top