Even and Odd in VBA

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

3 réponses

Le Pingou Posted messages 12375 Registration date   Status Contributeur Last intervention   1 476
 
Hello,
Take a quick look here: https://grenier.self-access.com/access/etats/pages-paires-et-impaires-dans-un-etat/

--
Best regards.
The Penguin
1
PapyLuc51 Posted messages 4566 Registration date   Status Membre Last intervention   1 509
 
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
0
Anonymous user
 
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
0
PapyLuc51 Posted messages 4566 Registration date   Status Membre Last intervention   1 509 > Anonymous user
 
Hello RoMa_31
Yes, that’s what I mention in the first sentence of my response; the rest is to remind of the other possibility with functions

Best regards
0
Anonymous user > PapyLuc51 Posted messages 4566 Registration date   Status Membre Last intervention  
 
Indeed!
I skimmed through your response ;-)
0
Tessel75
 
Thank you for the response, I will look at the link because actually I will need to use it with Access if necessary by creating a new personal function.
0
Tessel75
 
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.
0