The following code was not originally my code and I am not an expert with this stuff, but I found an error in it, and for the life of me, I can't understand why it's not working properly. So I have the actual code set up in a macro.......
Do While Data.Cells(x, 5) <> ""
If CurrentTrend = 1 Then ' CurrentTrend = UP
NewPrice = Data.Cells(x, 3) ' days high
If NewPrice >= CurrentPrice + BlockSize Then ' mark up
Do While NewPrice >= CurrentPrice + BlockSize
ChartRow = ChartRow - 1
ChartP.Cells(ChartRow, ChartCol) = "X"
CurrentPrice = CurrentPrice + BlockSize
Loop
CurrentPrice, NewPrice, and BlockSize are set as Double
In this example, the the data is being pulled correctly.......
CurrentPrice is 87.75 and BlockSize is .05.
It pulls NewPrice which is 87.80.
Now when I hover the mouse pointer in the VBA Editor during a step by step test at each variable, I can clearly see that NewPrice (showing as 87.80) >= CurrentPrice (showing as 87.75) + BlockSize (showing as .05). So then 87.80 is Greater Than Or Equal to 87.80. In this case it is obviously equal. Unfortunately it doesn't go down to the next step which it should. What is most interesting is that if I change the NewPrice.... code to "NewPrice = Data.Cells(x, 3) + .001 ' days high" it totally works. Now doing it this way might work without any issues. I haven't figured that out yet, but that really shouldn't be the answer since it does leave me with a situation in which there could be other errors I that I am not thinking about. For whatever reason, the equal part of the operation seems to be ignored. It's as if I only asked for > than instead of >=. Any ideas?
Do While Data.Cells(x, 5) <> ""
If CurrentTrend = 1 Then ' CurrentTrend = UP
NewPrice = Data.Cells(x, 3) ' days high
If NewPrice >= CurrentPrice + BlockSize Then ' mark up
Do While NewPrice >= CurrentPrice + BlockSize
ChartRow = ChartRow - 1
ChartP.Cells(ChartRow, ChartCol) = "X"
CurrentPrice = CurrentPrice + BlockSize
Loop
CurrentPrice, NewPrice, and BlockSize are set as Double
In this example, the the data is being pulled correctly.......
CurrentPrice is 87.75 and BlockSize is .05.
It pulls NewPrice which is 87.80.
Now when I hover the mouse pointer in the VBA Editor during a step by step test at each variable, I can clearly see that NewPrice (showing as 87.80) >= CurrentPrice (showing as 87.75) + BlockSize (showing as .05). So then 87.80 is Greater Than Or Equal to 87.80. In this case it is obviously equal. Unfortunately it doesn't go down to the next step which it should. What is most interesting is that if I change the NewPrice.... code to "NewPrice = Data.Cells(x, 3) + .001 ' days high" it totally works. Now doing it this way might work without any issues. I haven't figured that out yet, but that really shouldn't be the answer since it does leave me with a situation in which there could be other errors I that I am not thinking about. For whatever reason, the equal part of the operation seems to be ignored. It's as if I only asked for > than instead of >=. Any ideas?