need help in formula

VBABEGINER

Well-known Member
Joined
Jun 15, 2011
Messages
1,284
Office Version
  1. 365
Platform
  1. Windows
Hi All,

In my below formula, I'm, checking few condition's.
If F cell value blank or with date of (1900,1,1) then it written blank else
if F cell value not blank or with any other date and now K cell value blank then as per the red color part I need answer else
if F cell value not blank or with any other date and now here K cell value is not blank then as per the blue color part I need answer..

Can anyone please help here..

Rich (BB code):
=IF(OR(F75558="",F75558=DATE(1900,1,1)),"",
IF(K75558="",
IF(H75558<=5,"Week 1",
IF(H75558<=10,"Week 2",
IF(H75558<=20,"Week 3 & 4",
IF(H75558<=30,"Week 5 & 6",
IF(H75558<=40,"Week 7 & 8",
IF(H75558<=50,"Week 9 & 10",
IF(H75558<=60,"Week 11 & 12",
IF(H75558<=70,"Week 13 & 14",
IF(H75558<=80,"Week 15 & 16",
IF(H75558<=85,"Week 17",
IF(H75558<=100,"Week 18 & 20",
IF(H75558<=115,"Week 21 & 23",
IF(H75558<=130,"Week 24 & 26",
IF(H75558<=131,"Week 27 onwards",

IF(K75558<>"",
IF(H75558<=10,"Week 1 & 2",
IF(AND(H75558>10,H75558<=20),"Week 3 & 4",
IF(AND(H75558>20,H75558<=30),"Week 5 & 6",
IF(AND(H75558>30,H75558<=40),"Week 7 & 8",
IF(AND(H75558>=40,H75558<=60),"Week 9 & 12",
IF(AND(H75558>60,H75558<=75),"Week 13 & 15",
IF(AND(H75558>75,H75558<=90),"Week 16 & 18",
IF(AND(H75558>90,H75558<=105),"Week 19 & 21",
IF(AND(H75558>105,H75558<=120),"Week 22 & 24","Full"))))))))))
 
Last edited by a moderator:

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
This seems like something youd put in a lookup table, instead of code.
Then you submit the parameter, then it looks up the return value.
 
Upvote 0
This seems like something youd put in a lookup table, instead of code.
Then you submit the parameter, then it looks up the return value.
Thank You for your reply.. But Can I get something specific what to put across
 
Upvote 0
insert a new module and paste the function into it.

usage:
in sheet1, enter 50 in "A2" and put function in A3 as: =GetCaption(A2)

Code:
Public Function getCaption(ByVal piGivenVal As Integer)
Dim r As Integer
Dim vCurrVal
Dim bFound As Boolean


r = 0
Sheets("table").Activate
vCurrVal = Sheets("table").Range("A2").Value

    While vCurrVal <> "" And Not bFound
       If piGivenVal <= vCurrVal Then
          getCaption = Sheets("table").Range("A2").Offset(r, 1).Value
          bFound = True
       End If
    
       r = r + 1
       vCurrVal = Sheets("table").Range("A2").Offset(r, 0).Value  'next row
    Wend
End Function


the "table" tab data looks like 2 columns:
LIMIT , NAME
5 , Week 1
10, Week 2
20 , Week 3 & 4
30 , Week 5 & 6
40, Week 7 & 8
50, Week 9 & 10
60 , Week 11 & 12
70, Week 13 & 14
80, Week 15 & 16
85, Week 17
100 , Week 18 & 20
115, Week 21 & 23
130, Week 24 & 26
131, Week 27 onwards
 
Upvote 0
insert a new module and paste the function into it.

usage:
in sheet1, enter 50 in "A2" and put function in A3 as: =GetCaption(A2)

Code:
Public Function getCaption(ByVal piGivenVal As Integer)
Dim r As Integer
Dim vCurrVal
Dim bFound As Boolean


r = 0
Sheets("table").Activate
vCurrVal = Sheets("table").Range("A2").Value

    While vCurrVal <> "" And Not bFound
       If piGivenVal <= vCurrVal Then
          getCaption = Sheets("table").Range("A2").Offset(r, 1).Value
          bFound = True
       End If
   
       r = r + 1
       vCurrVal = Sheets("table").Range("A2").Offset(r, 0).Value  'next row
    Wend
End Function


the "table" tab data looks like 2 columns:
LIMIT , NAME
5 , Week 1
10, Week 2
20 , Week 3 & 4
30 , Week 5 & 6
40, Week 7 & 8
50, Week 9 & 10
60 , Week 11 & 12
70, Week 13 & 14
80, Week 15 & 16
85, Week 17
100 , Week 18 & 20
115, Week 21 & 23
130, Week 24 & 26
131, Week 27 onwards
Thank You RanMan.. I appreciate your time and effort to resolve issue and help someone.. Give me little time to check at my end..
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top