Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
excel
I am trying to create a formula, which I am not the best at. I seem to make
it too long. I want it to say if a cell = 2 or 3 it should be 1162. if it is a 4, 5 or less than 637999 then it is 1172. If is is greater than 638000 then it should be 1162 everything else is 1162. Help!! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
excel
Open the VB Editor, insert a module and paste the following function into the
module: Function MatchValue(CellValue As Long) As Long Dim l As Long Application.Volatile Select Case CellValue Case 1 l = 0 Case 2 To 3 l = 1162 Case 4 To 637999 l = 1172 Case Else l = 1162 End Select MatchValue = l End Function To use it just enter it like you would any formula, for example: =MatchValue(A1) -- Kevin Backmann "Sonia" wrote: I am trying to create a formula, which I am not the best at. I seem to make it too long. I want it to say if a cell = 2 or 3 it should be 1162. if it is a 4, 5 or less than 637999 then it is 1172. If is is greater than 638000 then it should be 1162 everything else is 1162. Help!! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
excel
If I'm reading this correctly...
If your reference cell is 4-637999 then set the cell to 1172, otherwise set to 1162. The following formula would do that (in this example A1 is the reference cell)... =IF(AND(A1=4,A1<=637999),1172,1162) Hope this is of some use, Wayne |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
excel
The conditions =4 and =5 are included in the condition <637999 and so
are redundant. The condition 638000 is included in the condition "everything else." Suppose the value you are evaluating is in A1. Then, all you need is the untested formula =IF(OR(A1=2,A1=3),1162,IF(A1<637999,1172,1162)) -- Regards, Tushar Mehta www.tushar-mehta.com Excel, PowerPoint, and VBA add-ins, tutorials Custom MS Office productivity solutions In article , says... I am trying to create a formula, which I am not the best at. I seem to make it too long. I want it to say if a cell = 2 or 3 it should be 1162. if it is a 4, 5 or less than 637999 then it is 1172. If is is greater than 638000 then it should be 1162 everything else is 1162. Help!! |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
excel
The 2s 3s and everyhting else part doesn't work.
"Kevin B" wrote: Open the VB Editor, insert a module and paste the following function into the module: Function MatchValue(CellValue As Long) As Long Dim l As Long Application.Volatile Select Case CellValue Case 1 l = 0 Case 2 To 3 l = 1162 Case 4 To 637999 l = 1172 Case Else l = 1162 End Select MatchValue = l End Function To use it just enter it like you would any formula, for example: =MatchValue(A1) -- Kevin Backmann "Sonia" wrote: I am trying to create a formula, which I am not the best at. I seem to make it too long. I want it to say if a cell = 2 or 3 it should be 1162. if it is a 4, 5 or less than 637999 then it is 1172. If is is greater than 638000 then it should be 1162 everything else is 1162. Help!! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|