Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 22nd, 2010, 01:28 AM
Authorized User
 
Join Date: Apr 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Basic IsNumeric Function help

I have made this custom function to check cells B4-B8 to see that they are Numeric. My goal is to use this function in worksheet formulas.
I would like to access this function in my formula via an "if then" statement, i.e. "=if(VCDataNumeric=true,"Do this", "Do that")"

That is my ultimate goal, and not sure how to get it to work correctly. Any pointers would be great!

Code:
Function VCDataNumeric() As Boolean
'   Determines if all entered data in VC boxes are NUMERIC
'   Returns TRUE if all inputs are NUMERIC

Dim PVIstation As Double: PVIstation = Range("B4").Value
Dim PVIelevation As Double: PVIelevation = Range("B5").Value
Dim VClength As Double: VClength = Range("B6").Value
Dim g1 As Double: g1 = Range("B7").Value
Dim g2 As Double: g2 = Range("B8").Value
    If IsNumeric(PVIstation) And IsNumeric(PVIelevation) And IsNumeric(VClength) And IsNumeric(g1) And IsNumeric(g2) Then VCDataNumeric = True
    Else
        VCDataNumeric = False
    End If
End Function
 
Old August 22nd, 2010, 02:02 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

Can you check if data validation (Data-->Validation) cna solve your problem

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old August 22nd, 2010, 02:41 AM
Authorized User
 
Join Date: Apr 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, Data validation would help, however, I have other cells that have formulas that are dependant upon B4-B8 beinge Numeric.
Right now, in those "other" cells with formulas, I have an if-then statement, with isnumber function. I am just trying to make my other cell formulas a bit more readable and shorter.

Also, when I get the function to work, What would be the syntax for the cell formula?
 
Old August 22nd, 2010, 10:46 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

I thibk you can then try with Worksheet_Change event. This event gets fired when something gets changed in the cells. You can check for numeric here and can take appropriate action
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling Oracle Function from Visual Basic 6.0 sanju_0071 Pro VB Databases 0 June 25th, 2009 07:07 PM
IsNumeric ? Berggreen C# 1 June 21st, 2006 07:05 PM
Integrating SQL with visual basic function, how?? Calverstine VB Databases Basics 0 October 23rd, 2005 12:29 AM
Integrating SQL with visual basic function, how?? Calverstine VB How-To 0 October 23rd, 2005 12:27 AM
ISNUMERIC function ram2098 SQL Server 2000 2 November 3rd, 2003 03:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.