Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try this one:
Sub TestFormula() If ([n4] -1 And [n4] < 31) Then [a1] = "'1-30" ElseIf ([n4] 30 And [n4] < 61) Then [a1] = "'31-60" ElseIf ([n4] 60 And [n4] < 100) Then [a1] = "'61-99" ElseIf ([n4] 99) Then [a1] = "'Error!" End If End Sub -- Regards, Halim "Alan M" wrote: I have the following formula which works fine in a worksheet: =IF(AND(N4-1,N4<31)=TRUE,"1-30",IF(AND(N430,N4<61)=TRUE,"31-60",IF(AND(N460,N4<100)=TRUE,"61-99",IF(N499=TRUE,"100+","Error!")))) However, when I try to use VBA code to enter the formula using this ( which is basically the same thing) Range("S2").FormulaR1C1 = _ "=IF(AND(RC[-1]-1,RC[-1]<31 = TRUE,"1", _ IF(AND(RC[-1]30,RC[-1]<61 =TRUE,"31-60", _ IF(AND(RC[-1]60,RC[-1]<100) =TRUE, "61-99", _ IF(RC[-1]99 = TRUE,"100+"."ERROR!")))) I get a syntax error message Can anyone tell me how to get it to enter the formual automatically please? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
formula code | Excel Discussion (Misc queries) | |||
Help with Formula in Code | Excel Programming | |||
formula through vb code | Excel Programming | |||
Not sure if I need a formula or some code.... | Excel Programming | |||
SUM Formula using code | Excel Programming |