Loop expression won't recognize values are equal


New Member
Apr 20, 2012
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!


Board Regular
Feb 15, 2012
Have you checked the decimals? In the screenshot, I see that you're out to 2 decimals, but are the 3rd and 4th equal?


MrExcel MVP
May 26, 2009
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 ...


New Member
Apr 20, 2012
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!

Forum statistics

Latest member

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...