Loop expression won't recognize values are equal

fiveironfrnzy08

New Member
Joined
Apr 20, 2012
Messages
2
Hi all,

(Excel 2007)
The issue I'm having is that a loop statement of mine is failing to recognize that a couple values are equal. It works for the first 3 iterations of the loop, then stops recognizing. I tried copying another set of numbers in the failing one's place, and that actually worked.
I can't attach anything, so I'm including a link to a detailed screen shot with some notes on it and code that I'll host on my site.
Not sure how else to explain the issue, but if you take a look at the screen shot you can see the excel sheet being worked on and the vba code running. I will also include a text file of the code for anyone who would like to change the code to offer a suggestion.

Here are the links to the screen shot and text file of my code
Text file
Screen Shot

Thank you!
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Have you checked the decimals? In the screenshot, I see that you're out to 2 decimals, but are the 3rd and 4th equal?
 
Upvote 0
I haven't looked at your code, but just a thought, if you are basing an If statement on the equality of two numeric values you might want to round them as 54.15035 <> 54.15034 even though both appear on your sheet as 54.15, they are not equal. Try:
If Round(value1,2) =Round(value2,2) Then ...
 
Upvote 0
Thank you!
Round() did the trick. I thought it wasn't that because the variable watch showed them as out the same amount of decimals, but apparently not!

Thank you both for your timely assistance!
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,257
Members
449,075
Latest member
staticfluids

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