Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 28th, 2007, 01:54 PM
Registered User
Join Date: Jan 2007
Location: , , .
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.
Reply With Quote
  #2 (permalink)  
Old January 28th, 2007, 02:21 PM
Friend of Wrox
Join Date: Oct 2003
Location: , , Finland.
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts


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

Reply With Quote
  #3 (permalink)  
Old January 29th, 2007, 04:34 AM
Friend of Wrox
Join Date: Jun 2003
Location: London, , United Kingdom.
Posts: 173
Thanks: 0
Thanked 3 Times in 3 Posts

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:



Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 07:01 AM.

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