jeudi 16 février 2017

Excel VBA 'If Then Else' Statement fails

I'm new to SO, so please forgive any nuances I don't include in my question. I've come to you guys for help with some coding i'm writing in Excel VBA. I have a cell that is the sum of a range of cells which are filled with decimals and formatted as percents (e.g. Cell C4 = 40.00%, C4 actual value = 0.4). in my code I have an I/T statement that reads as follows:

If PC.Range("c16").Value = 1 Then

' do a bunch of stuff ' 

Else:

MsgBox "Percentages don't add to 100%."

The problem I have is, the order of that range of cells' values sometimes triggers the code to enter into the Else part of the code, even though the cell DOES = 1. Has anyone seen this or can anyone help? I can provide other info if necessary and I can even send the Excel code in its entirety if needed.

Thank you all in advance and I look forward to learning!

Chris

Aucun commentaire:

Enregistrer un commentaire