Insert Formula in Macros

TWINKLEMARVEL

Board Regular
Joined
Sep 24, 2008
Messages
101
Pls help me out to insert the below formula in the macro given below. I need the formula to be in cell N2

Code:
=IF(L2="","",IF(L2=0,1,IF(L2<=4,L2,IF(AND(L2>=5,L2<=7),"a.5-7",IF(AND(L2>=8,L2<=15),"b.8-15",IF(AND(L2>=16,L2<=30),"c.16-30",IF(AND(L2>=31,L2<=60),"d.30-60","e.>60")))))))

Code:
Range("N2").Select
    ActiveSheet.Paste
    Range(Selection, Selection.End(xlDown)).Select
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Code:
Range("N2").FormulaR1C1 = _
        "=IF(R[1]C[10]="""","""",IF(R[1]C[10]=0,1,IF(R[1]C[10]<=4,R[1]C[10],IF(AND(R[1]C[10]>=5,R[1]C[10]<=7),""a.5-7"",IF(AND(R[1]C[10]>=8,R[1]C[10]<=15),""b.8-15"",IF(AND(R[1]C[10]>=16,R[1]C[10]<=30),""c.16-30"",IF(AND(R[1]C[10]>=31,R[1]C[10]<=60),""d.30-60"",""e.>60"")))))))"
 
Upvote 0
Pls help me out to insert the below formula in the macro given below. I need the formula to be in cell N2

Code:
=IF(L2="","",IF(L2=0,1,IF(L2<=4,L2,IF(AND(L2>=5,L2<=7),"a.5-7",IF(AND(L2>=8,L2<=15),"b.8-15",IF(AND(L2>=16,L2<=30),"c.16-30",IF(AND(L2>=31,L2<=60),"d.30-60","e.>60")))))))

Code:
Range("N2").Select
    ActiveSheet.Paste
    Range(Selection, Selection.End(xlDown)).Select


I'm not sure about where you want the formula, but maybe:

Code:
Range("N2").Formula = "=IF(L2="""","""",IF(L2=0,1,IF(L2<=4,L2,IF(AND(L2>=5,L2<=7),""a.5-7"",IF(AND(L2>=8,L2<=15),""b.8-15"",IF(AND(L2>=16,L2<=30),""c.16-30"",IF(AND(L2>=31,L2<=60),""d.30-60"",""e.>60"")))))))"
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

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