troubleshooting Question

Visual Basic Excel - value of cell with 0 evaluates to same value with cell that is blank

Avatar of BlairBrenner
BlairBrennerFlag for United States of America asked on
Microsoft OfficeVisual Basic ClassicVB Script
5 Comments2 Solutions481 ViewsLast Modified:
I am comparing values in cells of two work sheets.  The sheets are supposed to contain the same values.  

If a cell in one sheet does not correspond to the cell in the other sheet, then the program displays the unequal cells and stops.

If cell a1 in sheet1 has a value of 0 (zero) and cell a1 in sheet2 is blank, the following statement evaluates as false:
If (Worksheets("Sheet1").Cells(X, Y).Value <> Worksheets("Sheet2").Cells(X, Y).Value) Then

In other words, the statements after "Then" are skipped and the program checks the next pair of cells.

How can I get VB to realize 0 and blank are <>??


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros