PDA

View Full Version : Solved: 2 formulas required - Part 1



Hoopsah
06-25-2008, 12:28 AM
Hi,

I have a spreadsheet where there is a macro button that once clicked submits all the information to a spreadsheet/database.

What I am looking for is something to add into the code that will pop up an error message box if the conditions are not met.

The conditions are: If A1 is complete then B1 cannot be, if B1 is complete then A1 cannot be, If neither A1 or B1 is completed then show error too.

The second one I need help with is a working days scenario on a completely different spreadsheet, so I am going to post it on a completely different thread.

Cheers

Hoopsah

Bob Phillips
06-25-2008, 12:30 AM
If Range("A1").Value = "" OR Range("B1").VAlue = "" Then

MsgBox "Error"
Else

'... do your stuff
End If

Hoopsah
06-25-2008, 12:45 AM
Hi XLD,

thanks for that, I hadn't even got question 2 written.

This formula works if both cells are blank, but what I actually want is the user must input details into at least one cell.

Sorry for not being clear.

Bob Phillips
06-25-2008, 12:49 AM
No it tests OR not AND.

Hoopsah
06-25-2008, 01:48 AM
Hi again,

it is an OR but when I input into only one of the cells I get an error. I need to be able to input into one and not the other.

:confused4

Bob Phillips
06-25-2008, 02:37 AM
Sorry, is this what you want?



If (Range("A1").Value = "" And Range("B1").Value = "") Or _
(Range("A1").Value <> "" And Range("B1").Value <> "") Then

MsgBox "Error"
Else

'... do your stuff
End If

Hoopsah
06-25-2008, 02:46 AM
Man!

That is exactly it, works perfectly.

Thanks a lot for your time on these 2 problems today XLD

:ipray:

Hoopsah