#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,316
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default 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
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



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

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

About Us

"It's about Microsoft Excel"