Run formula while running loop vba

tenspeed2

Board Regular
Joined
Jan 25, 2011
Messages
56
Hi guys. I am trying to run a formula =xlqprice(Sym,"yahoo") in E1 and at the same time run a loop on column A. I used record macro to see what it looked like
in code. I then inserted it in the loop as you can see. What is supposed to happen is while the loop is running thru column A each time the loop changes symbols
the formula is to change the market price. in E1. I cannot get the formula to run except when the loop reaches the end in column A. I think I am close to getting
the formula to run. I am sending the macro for you to look at. Any help? Thanks.
Sub ProcessData()


x = 1
While ActiveSheet.Range("a" & x).Formula <> ""
Range("E1").Select
ActiveCell.FormulaR1C1 = "=xlqPrice(RC[-1],""tda"")"
Range("J28").Insert xlDown
Range("J28").Value = Range("J27").Value
ActiveSheet.Range("D1").Formula = ActiveSheet.Range("a" & x).Formula
ltime = Timer()
While Timer() - ltime < 7
DoEvents
Wend
x = x + 1
Wend
End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Try adding

ActiveSheet.Calculate
You have bad hair. LOL I put ActiveSheet.Calculate in right above Range ("E1").Select.
No luck. Did I put it in the wrong place?
Thanks for the quick response. The formula will only work for me as it is a payfor It seems to me that if the Loop command
works, then why does the calculate command not work? I am pulling my hair out.LOL
Max
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,962
Latest member
Fenes

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