LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default complex functions with scenarios and relative addresses

I am trying to write a function that will help me to budget for multiple
scenarios. Function: SalaryAmt,

Sample Datasheet:

A B C D E F G H I J
1 Month1 Month2 Month3 Month4
2 UseSalary 1 1 2 3
3 Annual Annual Annual 1/1/2005 2/1/2005 3/1/2005 4/1/2005
4 Name StartDate EndDate Salary1 Salary2 Salary3
5
6 Tom 1/1/2005 2/28/2005 10000 23000 43000 =fn =fn =fn =fn
7 Dick 3/1/2005 12000 14000 16000 =fn =fn =fn =fn
8 Harry 3/1/2005 14000 16000 18000 =fn =fn =fn =fn
9 Sally 4/1/2005 35000 38000 40000 =fn =fn =fn =fn


The scenarios, the numbers on row2 following UseSalary, are calculated on
another sheet and are based on net revenues for that month. One variable as
to how much a person can be paid is the net revenue situation.

If I insert the SalaryAmt function in any cell in within G6:J9 (the range
will change as I add months and people), the following is my attempt at the
proper logic:

€˜ I am assuming that the active cell is already formatted for currency, no
$, no decimals.
€˜ I think the function needs to know where it is

NowIamAt_r = ActiveCell row
NowIamAt_c = ActiveCell column

returnvalue= AS currency
loopcontrol=.T.

DOWHILE loopcontrol

€˜ First test, should the person be paid this month? They should not be paid
if the EndDate applies

IF Month1Date [NowIamAt_c,$3] is EndDate [$C,NowIamAt_r]

returnvalue = $ 0
loopcontrol=.F.
EXIT

ENDIF

€˜ If there is no EndDate, then need to see if the start date is same or
earlier than this months date

IF ThisMonthDate [NowIamAt_c,$3] is = StartDate [$B,NowIamAt_r]
€˜ It this test is passed, need to fill in value for the governing scenario
Select.case
Case [NowIamAt_c$2] = €œ1€
returnvalue = ([$D, NowIamAt_r]/12)
Case [NowIamAt_c$2] = €œ2€
returnvalue = ([$E, NowIamAt_r]/12)
Case [NowIamAt_c$2] = €œ3€
returnvalue = ([$F, NowIamAt_r]/12)
Case [NowIamAt_c$2] < €œ1€
Change variable type to text
returnvalue = €œerror<1€
Case [NowIamAt_c$2] €œ3€
Change variable type to text
returnvalue = €œerror3€
ENDCASE

ELSE

€˜If test is not passed, returnvalue is zero

returnvalue = 0

ENDIF

Loopcontorl = .F.

ENDDO


 
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
Macro - getting relative cell addresses to flow down Chris Excel Discussion (Misc queries) 1 August 25th 06 09:27 PM
How do I change a macro to use relative cell addresses? Roger D Excel Discussion (Misc queries) 2 July 30th 05 07:35 PM
How do I change a Macro to use relative cell addresses? Roger D Excel Discussion (Misc queries) 1 July 30th 05 07:00 PM
Relative Addresses in equations OkieViking Excel Programming 11 January 24th 05 12:03 PM
Using Relative Addresses to Select Columns Andrew Rallings Excel Programming 1 August 13th 03 01:28 AM


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