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: 24
Default Trouble referencing the correct cell. Function will not work.

Hello, I am new to VBA and I am trying to create a formula that will
reference my variable "AW" and based on the range of numbers it falls
between returns the formula you see listed in my IF...then
statements. Any help would be appreciated.

Right now, my function always returns a value of zero. Thanks.



Function AVGCASEVAR(Avg_Cases_Wk, AW)
' Calulates the variance in Cases of beer used per week versus an
average as determined by the appropiate tier.
Dim Tier1 As Long, Tier2 As Long
Dim Tier3 As Long, Tier4 As Long
Dim Tier5 As Long
Dim Avg_Cases_Week As Long
Tier1 = Range("$H$743")
Tier2 = Range("$H$744")
Tier3 = Range("$H$745")
Tier4 = Range("$H$746")
Tier5 = Range("$H$747")
If AW < 3000 Then AVGCASEVAR = Tier1 - Avg_Cases_Wk
[ElseIf AW 3000 AND <= 4000 Then [AVGCASEVAR = Tier2 -
Avg_Cases_Wk]]
[ElseIf AW 4000 AND <= 5000 Then [AVGCASEVAR = Tier3 -
Avg_Cases_Wk]]
[ElseIf AW 5000 AND <= 6000 Then [AVGCASEVAR = Tier4
- Avg_Cases_Wk]]
[Else: [AVGCASEVAR = Tier5 - Avg_Cases_Wk]]
End Function
 
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
Getting the correct reference cell to work Derek Excel Discussion (Misc queries) 5 June 2nd 08 06:52 PM
If I have a work sheet protected and try to run a macro to hide rows or columns it won't work. Correct? Marc Excel Programming 2 July 12th 06 04:10 AM
Ok, here is the Correct equation I am having trouble with€¦ (from T Ted Excel Worksheet Functions 11 November 20th 05 07:36 PM
I want to correct a #div/0! error but the IF function doesnt work Traceyb Excel Worksheet Functions 1 July 21st 05 03:47 PM
referencing other work book using the INDIRECT function jC! Excel Programming 2 December 2nd 03 08:14 AM


All times are GMT +1. The time now is 09:58 AM.

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"