PDA

View Full Version : [SOLVED:] If statement with non numeric cells



joshua1990
09-13-2017, 07:15 AM
Hey guys!

I'm currently working on a tool for the visualization of different processes.
I have a sheet with 2 datasets and a respective sum-function.
There are 2 cells to get the respective sum.

The objective is now, to get a MsgBox with the alert ,if both cells are not 100%, where the user has the choice to continue or to check the cells. The Msgbox will be opening at the clicking at a button.
The problem is there are some cells with a non numeric structure. Non-values are defined with "-".

How is this possible to manage?

Best regards
20321

SamT
09-13-2017, 07:48 AM
if both cells are not 100%,
"100%" What? Value? That's a simple Validation with a Warning.

"100%" Equal? Well, you're already talking about Buttons and MsgBoxes, so use VBA to accomplish the whole thing.

In either case, we will need a very detailed description of the Cells involved and how they relate. Addresses, Types of Values, which are Summed, which are compared, etc.

You can "Go Advanced" and use the Manage Attachments button on the lower part of the page to upload certain files, including Workbooks, here.

mdmackillop
09-13-2017, 07:49 AM
Not clear what you are after. For the message box try

MsgBox ([C12] = 1 And [C26] = 1)
For the data, use 0 value rather than text "-" with a custom format of 0.00%;-0.00%;-

joshua1990
09-13-2017, 08:02 AM
I'm sorry about my bad description.

There is already a map/ sample included in the first post.

My current code follows this approach:


Sub CheckSum()

Dim AnswerAs Integer
Dim sE As Range
Dim sV As Range
Dim



Set sE = Sheets("TblOne").Range("F30")
Set sV = Sheets("TblOne").Range("F52")


If sE<> 1 Or sV <> 1 Then

The problem is, in cell F30 and F52 is a excel-sum-function. There are no numeric values, only the function.
How can I add the result of this function into this code?
If the Value of one of both is under 100% or under 1, so a MsgBox should be displayed.

How can I manage this?

SamT
09-13-2017, 08:22 AM
Sub CheckSum()
Dim AnswerAs Integer
Dim sE
Dim sV

sE = Sheets("TblOne").Range("F30")
sV = Sheets("TblOne").Range("F52")

If IsNumeric(sE) And IsNumeric(sV) Then If sE*sV <> 1 Then
'
'
'
End If

joshua1990
09-13-2017, 08:47 AM
I'm sorry, it's not working.I have a new/ better example.

This is the sheet/ table:

20326

The objective is to get a msgbox if both sums are not 100%/ 1.
The cell for the respective sum is an excel-function. There is no value originally.

With the latest code, unfortunately, it's not working.

Here is the example file:

snb
09-13-2017, 09:04 AM
see

SamT
09-13-2017, 09:13 AM
The cell for the respective sum is an excel-function. There is no value originally.
The Formula for the cell is a Function, The Value is the result of the Function.

There is always a Value for all cells in Excel.