Here's a sample of one sub:-
Sub Part1Hr()
' W.Chong
Application.ScreenUpdating = False
'Application.Run "FifteenMnthCCheck"
Dim MSNCount As Variant
MSNCount = 0
Dim LoopCount As Variant
LoopCount = Range("PartCalcsHr!A4")
Worksheets("PartCalcsHr").Select
Rows("7:65536").Select
Selection.Delete Shift:=xlUp
Range("A7").Formula = "='Airbus Data'!E2"
Range("B7").Formula = "='Airbus Data'!B2"
Range("C6").Formula = "Part Drop Dead"
Range("C7").Formula = "=IF(HLOOKUP($A7,Constants!$C:$K,94,FALSE)=0,0,IF(IF('Raw Data'!$F7=0,0,((((HLOOKUP($A7,Constants!$C:$K,94,FALSE))-'Raw Data'!$E7)/'Raw Data'!$F7)*365)+'Raw Data'!$C7)>46022,46388,IF('Raw Data'!$F7=0,0,((((HLOOKUP($A7,Constants!$C:$K,94,FALSE))-'Raw Data'!$E7)/'Raw Data'!$F7)*365)+'Raw Data'!$C7)))"
Range("D7").Formula = "=IF(C7=0,0,LOOKUP(C7-90,'Raw Data'!$I7:$X7))"
Range("E7").Formula = "=YEAR(D7)"
Range("A7:E7").Select
Selection.AutoFill Destination:=Range(Cells(MSNCount + 7, Value + 1), Cells(LoopCount + 7, Value + 5)), Type:=xlFillDefault
Range(Cells(MSNCount + 7, Value + 4), Cells(LoopCount + 7, Value + 4)).Select
Selection.Copy
Range("A1").Select
Worksheets("Planner").Select
Cells(MSNCount + 7, Value + 1).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Selection.Replace What:="#n/a", Replacement:="0", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Range("D4").Formula = "=COUNTIF(PartCalcsHr!E:E,""2006"")"
Range("P4").Formula = "=COUNTIF(PartCalcsHr!E:E,""2007"")"
Range("AB4").Formula = "=COUNTIF(PartCalcsHr!E:E,""2008"")"
Range("AN4").Formula = "=COUNTIF(PartCalcsHr!E:E,""2009"")"
Range("AZ4").Formula = "=COUNTIF(PartCalcsHr!E:E,""2010"")"
Range("BL4").Formula = "=COUNTIF(PartCalcsHr!E:E,""2011"")"
Range("BX4").Formula = "=COUNTIF(PartCalcsHr!E:E,""2012"")"
Range("CJ4").Formula = "=COUNTIF(PartCalcsHr!E:E,""2013"")"
Range("CV4").Formula = "=COUNTIF(PartCalcsHr!E:E,""2014"")"
Range("DH4").Formula = "=COUNTIF(PartCalcsHr!E:E,""2015"")"
Range("DT4").Formula = "=COUNTIF(PartCalcsHr!E:E,""2016"")"
Range("EF4").Formula = "=COUNTIF(PartCalcsHr!E:E,""2017"")"
Range("ER4").Formula = "=COUNTIF(PartCalcsHr!E:E,""2018"")"
Range("FD4").Formula = "=COUNTIF(PartCalcsHr!E:E,""2019"")"
Range("FP4").Formula = "=COUNTIF(PartCalcsHr!E:E,""2020"")"
Range("GB4").Formula = "=COUNTIF(PartCalcsHr!E:E,""2021"")"
Range("GN4").Formula = "=COUNTIF(PartCalcsHr!E:E,""2022"")"
Range("GZ4").Formula = "=COUNTIF(PartCalcsHr!E:E,""2023"")"
Range("HL4").Formula = "=COUNTIF(PartCalcsHr!E:E,""2024"")"
Range("HX4").Formula = "=COUNTIF(PartCalcsHr!E:E,""2025"")"
Range("IJ4").Formula = "=COUNTIF(PartCalcsHr!E:E,""2026"")"
Range("D7").Select
Line1:
If MSNCount < LoopCount Then
'Drop Dead Date
Worksheets("PartCalcsHr").Select
Dim YrA As Variant
YrA = Year(Cells(MSNCount + 7, Value + 3))
If YrA > 0 Then
YrA = ((YrA - 2006) * 12)
End If
Worksheets("PartCalcsHr").Select
'Drop Dead Date
Dim MonthA As Variant
MonthA = Month(Cells(MSNCount + 7, Value + 3))
Worksheets("Planner").Select
'Drop Dead Date
If YrA > 0 Then
If YrA <= 251 Then
Cells(MSNCount + 7, MonthA + YrA + 3).Select
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 3
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 3
End With
With Selection.Borders(xlDiagonalDown)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 3
End With
'With Selection.Interior
' .ColorIndex = 3
' .Pattern = xlSolid
'End With
Else
Cells(MSNCount + 7, Value + 3).Select
With Selection.Interior
.ColorIndex = 32
.Pattern = xlSolid
End With
End If
Else
Cells(MSNCount + 7, Value + 3).Select
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
End If
MSNCount = MSNCount + 1
GoTo Line1
End If
Range("D7").Select
Worksheets("Planner").ComboBox2.Value = ""
End Sub
I thought about just changing it using varibles, but the problem is the change between each function is contained within the .Formula i.e
Range("C7").Formula = "=IF(HLOOKUP($A7,Constants!$C:$K,XXX,FALSE)=0,0,IF(IF('Raw Data'!$F7=0,0,((((HLOOKUP($A7,Constants!$C:$K,XXX,FALSE))-'Raw Data'!$E7)/'Raw Data'!$F7)*365)+'Raw Data'!$C7)>46022,46388,IF('Raw Data'!$F7=0,0,((((HLOOKUP($A7,Constants!$C:$K,XXX,FALSE))-'Raw Data'!$E7)/'Raw Data'!$F7)*365)+'Raw Data'!$C7)))"
where the XXX is what changes!
:/
Will
![[hammer] [hammer] [hammer]](/data/assets/smilies/hammer.gif)