IsEven/IsOdd "sub or function not defined". A reference problem?

303 views
Skip to first unread message

TJ

unread,
May 18, 2014, 12:51:47 PM5/18/14
to exce...@googlegroups.com
Hi,
 
I'm trying to use IsEven or IsOdd function in a vba project but am getting the "sub or function not defined" error. I just can't figure out why. The function works fine in the spreadsheet as a formula in any cell. Guessing it's a missing reference problem?
 
I checked the Tools|References after hitting Alt+F11 and found "Visual Basics For Applications" (VBA 7.1) and "Microsoft Excel 15.0 Object Library" checked (they can't be removed).
 
Your help is greatly appreciated.
 
TJ

DILIPandey

unread,
May 19, 2014, 1:50:29 AM5/19/14
to exce...@googlegroups.com, TJ
Hi TJ,

It is working fine in my system.
I used below code to check:-

Sub DILIPandey()
n = Application.WorksheetFunction.IsEven(Range("a1"))
End Sub

I don't think it is because of any reference issue but when I checked, I found below four references in use.

Visual Basic For Applications
Microsoft Excel 14.0 Object Library
OLE Automation
Microsoft Office 14.0 Object LIbrary

Out of these, I can't remove first two references.

Regards,
DILIPandey


--
You received this message because you are subscribed to the Google Groups "excel vba" group.
To unsubscribe from this group and stop receiving emails from it, send an email to excel-vba+...@googlegroups.com.
To post to this group, send email to exce...@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-vba.
For more options, visit https://groups.google.com/d/optout.



--
Thanks & Regards,

DILIP KUMAR PANDEY, mvp
               MBA,BCA,B.Com(Hons)
UAE +971 528225509 India +91 9810929744
dilip...@gmail.com, dilip...@yahoo.com

Skype: dilipandey | Gtalk: dilipandey | Yahoo: dilipandey

TJ

unread,
May 21, 2014, 5:42:40 PM5/21/14
to exce...@googlegroups.com, TJ
Apparently placing WorksheetFunction infront of the IsEven/IsOdd is the ticket!
 
Solution: WorksheetFunction.IsEven(A Number) instead of IsEven(A Number)
 
Thanks very much for your help, DILIPandey.
 
It is "odd" that the Microsoft Support website gave an example without the "WorsheetFunction" in front of the IsEven:
 
 
TJ

DILIPandey

unread,
May 22, 2014, 1:21:52 AM5/22/14
to exce...@googlegroups.com
You are welcome TJ


Regards,
DILIPandey
Reply all
Reply to author
Forward
0 new messages