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 January 28th, 2007, 01:54 PM
Registered User
 
Join Date: Jan 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Please help with function

i tried getting help at a different forum but was treated like crap, and no body would help me. So, ive come here because everyone seems nice and knowledgeable.

Im trying to make it so: if 15 is entered in cell A1 then show 2 in cell A3, if 16 is entered into cell A1 then show 3 in cell A3, if 17 is entered into cell A1 then show 4 in cell A3 etc... and if the number is less than 15 show 0.

i've tried just about everything and nothing works, i usually get the #NAME? error. can someone please help me out here, i would be eternally grateful. thank you.
 
Old January 28th, 2007, 02:21 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

This function is all you need

Function Sample(Number)
Select Case Number
    Case Is >= 15
        Sample = Number - 12
    Case Else
        Sample = 0
End Select
End Function

If you get #NAME you have mistyped function name


-vemaju
 
Old January 29th, 2007, 04:34 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 173
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Excuse me if you've already got this one cleared up but you can solve the problem with Excel worksheet formulae alone - no need for VBA. Just type the following in cell A3:

=MAX(A1-15,0)

HTH,
Maccas






Similar Threads
Thread Thread Starter Forum Replies Last Post
function keyvanjan ASP.NET 2.0 Professional 1 September 19th, 2007 10:22 AM
How to use Function akumarp2p SQL Server 2000 1 May 28th, 2007 05:04 AM
send variable in function to another function schoolBoy Javascript How-To 6 March 3rd, 2007 09:16 AM
How to call javascript function from VB function vinod_yadav1919 VB How-To 0 February 13th, 2006 06:03 AM
retreive function/Line from macro or function? MikoMax J2EE 0 April 1st, 2004 04:42 AM





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