I have this macro but i have 4 sheets & i want to put this formula in each sheet but Range is different in each sheet so please tell me how to do this.How different range of this formula put in particular sheet.Please tell me
Code:
Sub formula()
Dim myrange As Range, cell As Range
Dim lastrow As Long
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
lastrow = ActiveSheet.Range("a" & Rows.Count).End(xlUp).Row
MsgBox lastrow
Set myrange = ActiveSheet.Range("o2:o" & lastrow)
For Each cell In myrange
cell.FormulaR1C1 = _
"=RC[-14]&""-""&RC[-11]&""-""&RC[-9]&""-""&RC[-8]&""-""&RC[-7]&""-""&RC[-6]&""-""&RC[-5]&""-""&RC[-4]&""-""&RC[-3]&""-""&RC[-2]&""-""&RC[-1]"
cell.Offset(, 1).FormulaR1C1 = _
"=IF(COUNTIF(C[-1],RC[-1])>1,""Duplicate"",""Not Duplicate"")"
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
MsgBox "Done"
End Sub