Hello Everyone,
I am trying to write a macro that will iterate through a specified range of integers. This updates the value of a certain cell to be the value of the current integer, which in turn updates a table of data. A chart displays the data in the table in another worksheet. I need the chart to display the table for every iteration, but it currently does not update until the macro is done. I have tried to find a solution to this, but thanks to VBs help files, I have been unsuccessful so far. Here is the code for what I am trying to do, and some of my attempts to get it to work.
Declare Sub Sleep Lib "kernel32" (ByVal lMilliseconds As Long)
'This enables a timer in milliseconds to be used
Sub ChangeBatch()
For batch = ActiveSheet.Range("C2:C2") To ActiveSheet.Range("D2:D2") Step 1
'Gets the values for the min and max of the range
Worksheets("FDS").Range("Q1:Q1") = batch
'Updates the cell that the table (and therefore the chart) depends on
'Worksheets("HPLC Graph").ChartObjects(1).Chart.Refresh
'My first of many unsuccessful attempts
'Sheets("HPLC Graph").ChartObjects.Charts(1).Refresh
'This didn't work either
Application.CalculateFull
'I thought this would cause the table to update at least
'ActiveWorkbook.AciveSheet.Chart(1).Refresh
'Still nothing
Sleep ActiveSheet.Range("E2:E2") * 1000
'Pause for a specified amount of time to enable viewing of the data
Next
End Sub
And I've tried many, many more ideas, but none have worked. Most fail without even running. I think I'm really close to the solution, I just don't know the correct syntax to get it to work. I renamed the chart that I want to update as "HPLC" through the properties tab under Layout. I don't know if that helps.
Thanks for any help you may be able to provide.
Bookmarks