IsNumber "Sub or function not defined"

Glory

Well-known Member
Joined
Mar 16, 2011
Messages
640
IsNumber is listed in VBA's help as one of the "worksheet functions available to VBA", but when I try to use it, an error message appears.

What code do I use to determine whether a string contains one type of data or another?
 

Some videos you may like

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,782
Office Version
  1. 2010
Platform
  1. Windows
The VBA native IsNumeric function will tell you if a string can be converted to a number.

To use IsNumber (which does not tell you the same thing), you need to apply as WorksheetFunction.IsNumber
 

Glory

Well-known Member
Joined
Mar 16, 2011
Messages
640
Is that what i want to use in order to check to make sure that a user has inserted the right kind of information in a field?

I want to check to see whether a date actually consists of numbers or if the user has accidentally inserted a letter. I'm going to split the date at the delimiters and use "IsNumeric"?

What if I needed to make sure it was a bunch of letters?
 

Glory

Well-known Member
Joined
Mar 16, 2011
Messages
640
Also, what does it mean to say that a "worksheet function" is "available to VBA", if not that those functions can be used in VBA?
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,782
Office Version
  1. 2010
Platform
  1. Windows

ADVERTISEMENT

The native IsDate function will tell you if a string can be converted to a date and/or time.
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,782
Office Version
  1. 2010
Platform
  1. Windows
Also, what does it mean to say that a "worksheet function" is "available to VBA", if not that those functions can be used in VBA?
They can be used, Glory, but you need to preface it:

Code:
mySum = WorksheetFunction.Sum(Range("A1:A10").Value)
 
mySum = WorksheetFunction.Sum(myArray)
 

Watch MrExcel Video

Forum statistics

Threads
1,123,047
Messages
5,599,497
Members
414,315
Latest member
Yolanda5050

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top