Excel VBA seen in worksheet but comes upSub or function not defined in module

In a spreadsheet cell I can enter =FIND("M","abcdenfgMnc")  and it gives me 9

If I have this      res = Find("M", "abcdenfgMnc")
in a Public module it says compile error  Sub or function not defined

Get the same error when I put   ? Find("M", "abcdenfgMnc")
 in an immediate window
LVL 11
Donald MaloneyConsultantAsked:
Who is Participating?
 
Roy CoxConnect With a Mentor Group Finance ManagerCommented:
You cannot use a function like that in VBA. You need to use the .Find method. If you use a function in VBA you need to use

Application.WorkSheetFunction.Find)

Open in new window


Read this

What exactly are you doing?
0
 
Donald MaloneyConsultantAuthor Commented:
Coding VBA in an excel module.  Has been awhile.   Thank you
I have a string of numbers say in cell 1 with hyphens in between and was going to separate the numbers into cells e.g first in cell 2  second in cell 3 etc for a max of 20 numbers.  
I can do all that but it was bugging me why a simple vba function would not work in the called module.
0
 
Roy CoxGroup Finance ManagerCommented:
Pleased to help, but Text to Columns from the Data Tab would do that without VBA.
0
 
Donald MaloneyConsultantAuthor Commented:
Thanks  I'll check that
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.