Simultaneously animating cells

muraterguen

New Member
Joined
Jan 8, 2016
Messages
25
Hello,
In my file:
A1 has =SUM(A3:A100000) as a formula. B1 and C1 do the same addition for their columns...
The formula in A2 is =A1 , so I format this cell as a display. Same for B2 and C2.
Starting from A3, A1 does the addition every time a new number is entered into the cells to the bottom. A2 takes the data from A1 and continues displaying by animating in increments of 0.01 until it reaches the new number. Of course, the same is true for columns B and C.
There is VBA code for this, which I will share below.
The problem is;
These 3 separate cells are not working at the same time. If A is working, B and C are waiting, B starts when A's work is finished, C starts when B is finished. Can the macro code I shared be edited so that all 3 display cells work at the same time?
Thanks in advance

(I got this code written in ChatGPT)

Private Const DISPLAY_CELL_A = "A2"
Private Const DISPLAY_CELL_B = "B2"
Private Const DISPLAY_CELL_C = "C2"

Private DisplayCellA As Double
Private DisplayCellB As Double
Private DisplayCellC As Double

Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongLong)

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
DisplayCellA = Range(DISPLAY_CELL_A).Value
DisplayCellB = Range(DISPLAY_CELL_B).Value
DisplayCellC = Range(DISPLAY_CELL_C).Value
Call UpdateDisplayCellA
Call UpdateDisplayCellB
Call UpdateDisplayCellC
End Sub

Private Sub Worksheet_Calculate()
DisplayCellA = Range(DISPLAY_CELL_A).Value
DisplayCellB = Range(DISPLAY_CELL_B).Value
DisplayCellC = Range(DISPLAY_CELL_C).Value
Call UpdateDisplayCellA
Call UpdateDisplayCellB
Call UpdateDisplayCellC
End Sub

Private Sub UpdateDisplayCellA()
Dim A1 As Double
Dim SleepTime As Double

SleepTime = 100 ' Time to wait before updating the display cell in milliseconds
A1 = Range("A1").Value

Do While DisplayCellA < A1
DisplayCellA = DisplayCellA + 0.01
Range(DISPLAY_CELL_A).Value = DisplayCellA
If A1 <> Range("A1").Value Then
Exit Sub
End If
DoEvents ' Allows the user to cancel the operation by pressing Esc
Sleep SleepTime ' Pauses the macro for SleepTime milliseconds
Loop

Range(DISPLAY_CELL_A).Value = A1
End Sub

Private Sub UpdateDisplayCellB()
Dim B1 As Double
Dim SleepTime As Double

SleepTime = 100 ' Time to wait before updating the display cell in milliseconds
B1 = Range("B1").Value

Do While DisplayCellB < B1
DisplayCellB = DisplayCellB + 0.01
Range(DISPLAY_CELL_B).Value = DisplayCellB
If B1 <> Range("B1").Value Then
Exit Sub
End If
DoEvents ' Allows the user to cancel the operation by pressing Esc
Sleep SleepTime ' Pauses the macro for SleepTime milliseconds
Loop

Range(DISPLAY_CELL_B).Value = B1
End Sub

Private Sub UpdateDisplayCellC()
Dim C1 As Double
Dim SleepTime As Double

SleepTime = 100 ' Time to wait before updating the display cell in milliseconds
C1 = Range("C1").Value

Do While DisplayCellC < C1
DisplayCellC = DisplayCellC + 0.01
Range(DISPLAY_CELL_C).Value = DisplayCellC
If C1 <> Range("C1").Value Then
Exit Sub
End If
DoEvents ' Allows the user to cancel the operation by pressing Esc
Sleep SleepTime ' Pauses the macro for SleepTime milliseconds
Loop

Range(DISPLAY_CELL_C).Value = C1
End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Hi there...

I might be mistaken but I do not think this is possible. Macros run sequentially and not simultaneously. So UpdateCellA code will run and finish and then the next one will run...
 
Upvote 0
And you should inform here that you have this in another forum also. For the same reason as was explained there.
 
Upvote 0
the edit link has disappeared.
Please post it in a new reply to this thread (it does not necessarily have to be in the first post).
It looks like you have posted it in multiple places.
Please provide links to ALL those other forums you have posted this to.
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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