Eddie Estrella
New Member
Good Afternoon everyone,
I am trying to get this Sub Routine to add the formula based on if the cell is blank or not.
The loop goes through it's cycle, but only inserts a formula into cell Q2. This is my first attempt, but I can't see what I am missing. Thank you for you help
Sub getRealDemand()
Sheets("MatReq").Range("Q1").Value = "Combined OH"
If Range("C2").Value = "" Then
Range("Q2").Value = "=INDEX(Table1[OH],MATCH(B2,Table1[P#],0))+SUMIF(Portalinfo!$B$2:$B$766,B2,Portalinfo$H$2:$H$766)"
Else
Range("Q2").Value = "=INDEX(Table1[OH],MATCH(C3,Table1[Compo],0))"
End If
Range("D2").Select
Range("D2:D1841").Formula = "=SUM(E2
2)"
' Final Format
Range("A1:Q1").Interior.Color = RGB(146, 205, 220)
Range("A:Q").Columns.AutoFit
Range("D2").Select
ActiveWindow.FreezePanes = True
ActiveSheet.Range("A:Q").AutoFilter
End Sub
I am trying to get this Sub Routine to add the formula based on if the cell is blank or not.
The loop goes through it's cycle, but only inserts a formula into cell Q2. This is my first attempt, but I can't see what I am missing. Thank you for you help
Sub getRealDemand()
Sheets("MatReq").Range("Q1").Value = "Combined OH"
If Range("C2").Value = "" Then
Range("Q2").Value = "=INDEX(Table1[OH],MATCH(B2,Table1[P#],0))+SUMIF(Portalinfo!$B$2:$B$766,B2,Portalinfo$H$2:$H$766)"
Else
Range("Q2").Value = "=INDEX(Table1[OH],MATCH(C3,Table1[Compo],0))"
End If
Range("D2").Select
Range("D2:D1841").Formula = "=SUM(E2
' Final Format
Range("A1:Q1").Interior.Color = RGB(146, 205, 220)
Range("A:Q").Columns.AutoFit
Range("D2").Select
ActiveWindow.FreezePanes = True
ActiveSheet.Range("A:Q").AutoFilter
End Sub