Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default newbie needs help again, function returns 0 ONLY

Me again. As explained about a half hour ago, newbie user to VB. No
really sure of grammar and stuff and I can't see what's going on here
Basically, the formula takes the area of a building and assigns it
ranking integer. Any input result in as output of 0 (zero). Help..
btw, are there any good sites out there for a quick and dirty intro t
VB - grammar, basic functions and statements, etc.? Not excel specifi
necessarily... thanks. Oh! Here's the code:




Function SizeRank(Area As Integer) As Integer

If Area 10000 Then
Size = 1
ElseIf Area <= 10000 And Area 5000 Then
Size = 2
ElseIf Area <= 5000 And Area 2000 Then
Size = 3
ElseIf Area <= 2000 And Area 600 Then
Size = 4
ElseIf Area <= 600 Then
Size = 5
End If

End Functio

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default newbie needs help again, function returns 0 ONLY

Function SizeRank(Area As Integer) As Integer

If Area 10000 Then
Size = 1




The above line should be:

SizeRank = 1



ElseIf Area <= 10000 And Area 5000 Then
Size = 2
ElseIf Area <= 5000 And Area 2000 Then
Size = 3
ElseIf Area <= 2000 And Area 600 Then
Size = 4
ElseIf Area <= 600 Then
Size = 5
End If

End Function




You need to assign the value you want your function to return to the name of
the function.

--
Michael Hopwood


"whelanj " wrote in message
...
Me again. As explained about a half hour ago, newbie user to VB. Not
really sure of grammar and stuff and I can't see what's going on here.
Basically, the formula takes the area of a building and assigns it a
ranking integer. Any input result in as output of 0 (zero). Help...
btw, are there any good sites out there for a quick and dirty intro to
VB - grammar, basic functions and statements, etc.? Not excel specific
necessarily... thanks. Oh! Here's the code:




Function SizeRank(Area As Integer) As Integer

If Area 10000 Then
Size = 1
ElseIf Area <= 10000 And Area 5000 Then
Size = 2
ElseIf Area <= 5000 And Area 2000 Then
Size = 3
ElseIf Area <= 2000 And Area 600 Then
Size = 4
ElseIf Area <= 600 Then
Size = 5
End If

End Function


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default newbie needs help again, function returns 0 ONLY

Function SizeRank(Area As Integer) As Integer

If Area 10000 Then
SizeRank = 1
ElseIf Area <= 10000 And Area 5000 Then
SizeRank = 2
ElseIf Area <= 5000 And Area 2000 Then
SizeRank = 3
ElseIf Area <= 2000 And Area 600 Then
SizeRank = 4
ElseIf Area <= 600 Then
SizeRank = 5
End If

End Function

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"whelanj " wrote in message
...
Me again. As explained about a half hour ago, newbie user to VB. Not
really sure of grammar and stuff and I can't see what's going on here.
Basically, the formula takes the area of a building and assigns it a
ranking integer. Any input result in as output of 0 (zero). Help...
btw, are there any good sites out there for a quick and dirty intro to
VB - grammar, basic functions and statements, etc.? Not excel specific
necessarily... thanks. Oh! Here's the code:




Function SizeRank(Area As Integer) As Integer

If Area 10000 Then
Size = 1
ElseIf Area <= 10000 And Area 5000 Then
Size = 2
ElseIf Area <= 5000 And Area 2000 Then
Size = 3
ElseIf Area <= 2000 And Area 600 Then
Size = 4
ElseIf Area <= 600 Then
Size = 5
End If

End Function


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default newbie needs help again, function returns 0 ONLY

On Wed, 9 Jun 2004 13:42:27 -0500, whelanj
wrote:

Me again. As explained about a half hour ago, newbie user to VB. Not
really sure of grammar and stuff and I can't see what's going on here.
Basically, the formula takes the area of a building and assigns it a
ranking integer. Any input result in as output of 0 (zero). Help...
btw, are there any good sites out there for a quick and dirty intro to
VB - grammar, basic functions and statements, etc.? Not excel specific
necessarily... thanks. Oh! Here's the code:




Function SizeRank(Area As Integer) As Integer

If Area 10000 Then
Size = 1
ElseIf Area <= 10000 And Area 5000 Then
Size = 2
ElseIf Area <= 5000 And Area 2000 Then
Size = 3
ElseIf Area <= 2000 And Area 600 Then
Size = 4
ElseIf Area <= 600 Then
Size = 5
End If

End Function


Well, you never set SizeRank equal to anything. So it remains set at 0 which
is the default when you enter the function.

Try this (simplified a bit, also):

=============================
Function SizeRank(Area As Integer) As Integer

If Area 10000 Then
SizeRank = 1
ElseIf Area 5000 Then
SizeRank = 2
ElseIf Area 2000 Then
SizeRank = 3
ElseIf Area 600 Then
SizeRank = 4
Else
SizeRank = 5
End If

End Function
=============================

or, my preference:

==========================
Function SizeRank(Area As Integer) As Integer

Select Case Area
Case Is 10000
SizeRank = 1
Case Is 5000
SizeRank = 2
Case Is 2000
SizeRank = 3
Case Is 600
SizeRank = 4
Case Else
SizeRank = 5
End Select

End Function
==========================





---
Message posted from http://www.ExcelForum.com/


--ron
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function newbie Rubix Excel Worksheet Functions 2 November 12th 05 11:05 AM
Newbie: Help with OFFSET function CF Excel Worksheet Functions 3 October 1st 05 05:57 PM
Newbie: worksheet function help CF Excel Worksheet Functions 1 September 23rd 05 05:51 AM
I'm a newbie please help with my function colincannon New Users to Excel 3 August 30th 05 02:11 AM
Newbie needs a function (how sad) tjr Excel Worksheet Functions 12 January 24th 05 09:17 AM


All times are GMT +1. The time now is 02:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"