Hello everyone,
I am trying to input formulas into 80+ sheets with a varying number of rows. Below is the code I have that runs on the active sheet I am in(sheet7), and when running with stops, it shows that it goes to the next sheet(sheet8) but it's not actually writing the formulas in.
I also have the issue where, considering the number of rows vary, id like for the 'if formula' to go n29, n30, n31 and so on.
I am inputting the formula into column AG based on the number of rows with values in column N.
I am trying to input formulas into 80+ sheets with a varying number of rows. Below is the code I have that runs on the active sheet I am in(sheet7), and when running with stops, it shows that it goes to the next sheet(sheet8) but it's not actually writing the formulas in.
I also have the issue where, considering the number of rows vary, id like for the 'if formula' to go n29, n30, n31 and so on.
I am inputting the formula into column AG based on the number of rows with values in column N.
VBA Code:
Sub materialpricing()
Dim w As Long
Dim lrow As Long
Dim C As Range
Dim materialpricing As Variant
For w = 7 To ActiveWorkbook.Worksheets.Count
With ActiveWorkbook.Worksheets(w)
materialpricing= "=IF(N29=""delegated"",VLOOKUP(F29,'Deligated materials'!B:F,5,0),""Directed"")"
lrow = Cells(Rows.Count, "N").End(xlUp).Row
For Each C In Range("AG29:AG" & lrow)
C.Formula = materialpricing
Next
End With
Next w
End Sub