detect a change in sign in a do loop

abberyfarm

Well-known Member
Joined
Aug 14, 2011
Messages
733
Hi there,

I have acceleration for a car in a column, the values are positive and negative for acceleration and deceleration. I want to put a marker "1" in another column each time the sign changes, i.e the point when the car accelerates or decelerates.

I have a do loop set up below, but im not sure how to write the condition for "when the value of the sign changes"?

Would somebody be able to help me out?

Thanks

Code:
    Do

        If (ActiveCell.Offset(0, -11) = "sign changes") Then

        ActiveCell.Value = 1
       


        End If

    ActiveCell.Offset(1, 0).Select

    Loop Until IsEmpty(ActiveCell.Offset(0, -1))

this is what the data looks like
Code:
0.00
0.44
0.44
0.64
0.75
0.86
0.87
0.87
0.43
0.43
0.06
-0.03
-0.17
-0.42
-0.42
-0.44
-1.36
-1.42
0.06
0.06
0.06
0.92
0.94
0.99
0.99
0.99
-0.08
-0.72
-0.47
 
Last edited:

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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