ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Conditional testing (https://www.excelbanter.com/excel-programming/423507-conditional-testing.html)

John

Conditional testing
 
I have three cells, Cell1 is formatted as a text string, Cell2 a number and
Cell3 a date. If each contains a valid entry I want to do a block of code.
If any is empty, or if Cell2 or Cell3 contain text, I want to skip the code.
How do I write the If statement?

I appreciate your help, -John

SeanC UK[_2_]

Conditional testing
 
Hi John,

you can try something like:

If (IsEmpty(rng1) Or IsEmpty(rng2) Or _
IsEmpty(rng3)) Or (Not IsDate(rng2)) Or _
(Not IsNumeric(rng3)) Then
'BAD
Else
'OK
End If

Where rng1, 2 and 3 refer to the cells Text, Date and Number respectively.

Hope this helps,

Sean.
--
(please remember to click yes if replies you receive are helpful to you)


"John" wrote:

I have three cells, Cell1 is formatted as a text string, Cell2 a number and
Cell3 a date. If each contains a valid entry I want to do a block of code.
If any is empty, or if Cell2 or Cell3 contain text, I want to skip the code.
How do I write the If statement?

I appreciate your help, -John



All times are GMT +1. The time now is 03:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com