# Control rate of change of a cell using VBA?

1. ## Control rate of change of a cell using VBA?

Ok, here's one that I really have had no luck searching for...

I'm writing a little sheet to test some navigators on their basic speed/distance/time calculation skills. Ignore the clocks in Row 1, they're unrelated.

What I'd like is to simulate some basic acceleration / deceleration characteristics of a vehicle against a speed demand set point that the user enters. Obviously, no vehicle can go from any speed to another instantaneously, so I'd like my end users to have to take this into account when setting their demand speed.

Simply put, I'd like the actual speed in cell H4 to always target the demand speed in H3 and always return a result, but lag behind the demand speed slightly when changing.

I appreciate this is very basic - vehicles will have individual acceleration curves which are obviously non-linear, and acceleration and deceleration will be different to each other. But, for now, a simple linear control to limit the rate of change cell H4 would be terrific.

Roy K.

2. ## Re: Control rate of change of a cell using VBA?

Not sure if this is anywhere near to what you're looking for.
Formula:
`Please Login or Register  to view this content.`
slows down the increase of the actual speed.
The 60/20 part is there to adjust for accelleration power. Means 0 to 60 miles in 20 seconds. So you can play with the seconds.

3. ## Re: Control rate of change of a cell using VBA?

Hi there,

First up, thanks very much for your response, much appreciated!

The overall effect of that formula is roughly what I'm trying to achieve. Although it doesn't seem to work at all on deceleration, or when changing to a new target speed after one is reached.

But, yes, I think we're barking up the right tree, maybe!

4. ## Re: Control rate of change of a cell using VBA?

How is decelaration done?

5. ## Re: Control rate of change of a cell using VBA?

Deceleration will be done by moving the slider bar to the left to lower the demand speed, or by clicking either the "Stop" or "Crawl" preset speed buttons.

Also, you've used a reference to my H1 cell clock called "Rally Time". This isn't anything to do with the acceleration or speed part of my sheet, that will eventually just display laptop time, activated by opening the worksheet.

6. ## Re: Control rate of change of a cell using VBA?

Aha! The coin dropped, I think.
Didn't do it in a formula, but in the TickTock2 macro.
Also added cells for Acceleration and deceleration force.
Everything starts when clicking the StartRT button.
You can adjust the demand speed on the fly.

7. ## Re: Control rate of change of a cell using VBA?

Hi Tsjallie - just gave that a whirl and it looks absolutely perfect. I'm trying to get Rally Time to run from Worksheet_Open and reflect laptop time, once that's working I'll integrate your code.

But for now I'm calling this solved.

Very much appreciate the assistance, thank you!

There are currently 1 users browsing this thread. (0 members and 1 guests)