Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default VBA Module Function???

I have programmed the below function into a vba module:

Use a VBA function like the one below
call with
=bonus(b26,b27)

Function bonus(budget, actual)

Select Case (actual - budget)

Case -15 To -11
bonus = 1000
Case -10 To -4
bonus = 1500
Case -5 To -1
bonus = 1750
Case 0 To 4
bonus = 2000
Case 5 To 9
bonus = 2250
Case 10 To 14
bonus = 2500
Case 15 To 19
bonus = 3000
Case 20 To 24
bonus = 3250
Case 25 To 29
bonus = 3500
Case 30 To 34
bonus = 4000
Case 35 To 1000
bonus = 4500
End Select


End Function


Everything works fine, if I want to make another function like this that
wont interfere with the function already existing then how would i do this? I
tried opening up another module and changing the function name to usedbonus
and changing the numbers below but it says compile error and it messes with
the existing function in module 1. Can anyone help me???
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default VBA Module Function???

Can you post the code that you tried to use? You can put it in the same
module, but might be easier to maintain in a seperate one.
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Hamed parhizkar" wrote:

I have programmed the below function into a vba module:

Use a VBA function like the one below
call with
=bonus(b26,b27)

Function bonus(budget, actual)

Select Case (actual - budget)

Case -15 To -11
bonus = 1000
Case -10 To -4
bonus = 1500
Case -5 To -1
bonus = 1750
Case 0 To 4
bonus = 2000
Case 5 To 9
bonus = 2250
Case 10 To 14
bonus = 2500
Case 15 To 19
bonus = 3000
Case 20 To 24
bonus = 3250
Case 25 To 29
bonus = 3500
Case 30 To 34
bonus = 4000
Case 35 To 1000
bonus = 4500
End Select


End Function


Everything works fine, if I want to make another function like this that
wont interfere with the function already existing then how would i do this? I
tried opening up another module and changing the function name to usedbonus
and changing the numbers below but it says compile error and it messes with
the existing function in module 1. Can anyone help me???

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default VBA Module Function???

This is what I put in module 2

Function usedbonus(budget, actual)

Select Case (actual - budget)

Case -14 To -8
usedbonus = 750
Case -7 To -1
usedbonus = 1000
Case 0 To 6
usedbonus = 1250
Case 7 To 13
usedbonus = 1750
Case 14 To 1000
usedbonus = 2250
End Select


End Function



"Hamed parhizkar" wrote:

I have programmed the below function into a vba module:

Use a VBA function like the one below
call with
=bonus(b26,b27)

Function bonus(budget, actual)

Select Case (actual - budget)

Case -15 To -11
bonus = 1000
Case -10 To -4
bonus = 1500
Case -5 To -1
bonus = 1750
Case 0 To 4
bonus = 2000
Case 5 To 9
bonus = 2250
Case 10 To 14
bonus = 2500
Case 15 To 19
bonus = 3000
Case 20 To 24
bonus = 3250
Case 25 To 29
bonus = 3500
Case 30 To 34
bonus = 4000
Case 35 To 1000
bonus = 4500
End Select


End Function


Everything works fine, if I want to make another function like this that
wont interfere with the function already existing then how would i do this? I
tried opening up another module and changing the function name to usedbonus
and changing the numbers below but it says compile error and it messes with
the existing function in module 1. Can anyone help me???

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
vba excel - public function in module [email protected] Excel Programming 1 November 29th 07 11:58 AM
Calling a function in another module Barb Reinhardt Excel Programming 4 November 7th 06 03:14 PM
Insert function - custom function name preceded by module name [email protected] Excel Programming 1 April 2nd 06 03:46 PM
Sharing function in a module Julie Excel Programming 2 May 13th 04 06:04 PM
Calling VBA function that is in another module Jag Man Excel Programming 2 January 7th 04 03:37 AM


All times are GMT +1. The time now is 07:17 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"