Even and Odd in VBA
Tessel75
-
Tessel75 -
Tessel75 -
Hello everyone,
How do you write that a number is even or odd in VBA, please?
Thank you
Configuration: Windows / Firefox 93.0
How do you write that a number is even or odd in VBA, please?
Thank you
Configuration: Windows / Firefox 93.0
3 answers
-
Hello,
Take a quick look here: https://grenier.self-access.com/access/etats/pages-paires-et-impaires-dans-un-etat/
--
Best regards.
The Penguin -
Hello,
The practical sheet linked in the second link under the question (in the "See also" section) answers the request.
Another possibility is to use one of the two functions available, "IS.EVEN()" or "IS.ODD()"
The number in A1
=IF(IS.EVEN(A1),"EVEN","ODD")
or conversely if using the other
=IF(IS.ODD(A1),"ODD","EVEN")
Best regards-
Hello everyone,
PapuLuc51, the request is about VBA.
There's an article proposing several VBA methods here: https://www.commentcamarche.net/faq/48446-vba-test-si-un-nombre-est-pair-ou-impair
PS: we can add to the list the functions:
- WorksheetFunction.IsOdd(value_to_test) which returns TRUE/FALSE depending on whether the value to test is ODD/even
- WorksheetFunction.IsEven(value_to_test) which returns TRUE/FALSE depending on whether the value to test is EVEN/odd -
-
-
Very nice answer from LePingou, (we're used to it), it's exactly what I was looking for even though my problem was about continuous recording rather than odd and even pages.
I'm finishing writing my code; and then I will mark it as "resolved".
Thank you all for your efforts to help me reach a solution.