I am currently working on something in Excel, and I need certain formulas to be in certain cells, but I don't want to just auto fill the entire column for obvious reasons. I have the following VBA code which correctly inserts the formula if the appropriate field (H) equals no.
My problem is, I cannot seem to find a way to make the formulas update based off of the row number. Only instances where "8" is used, does the row number need to be dynamic and update based off the row, the rest of the options are static. Any help would be greatly appreciated.
Here is the current code - I will continue to experiment while I try to find a way to do it.
Dim x As Long
For x = 1 To 3008
If InStr(1, Sheet1.Range("$H$" & x), "No") <> No Then
Sheet1.Range("$K$" & x) = "=IF($C8="""",IF($B8="""","""",WORKDAY($B8,3,Admin!$B$5:$B$28)),WORKDAY($C8,3,Admin!$B$5:$B$28))"
Sheet1.Range("$L$" & x) = "=IF($H8=""No"",IF($B8="""","""",IF($C8="""",IF($E8=""Ulster Sterling"",IF($B8="""","""",WORKDAY($K8,10)),IF($E8=""Ulster Euro"",IF($B8="""","""",WORKDAY($K8,10)),WORKDAY($K8,15))),WORKDAY($K8,10))),"""")"
Sheet1.Range("$M$" & x) = "=IF($H8=""No"",IF(OR($L8=Admin!$B$5,$L8=Admin!$B$6,$L8=Admin!$B$8,$L8=Admin!$B$9,$L8=Admin!$B$10,$L8=Admin!$B$11,$L8=Admin!$B$13,$L8=Admin!$B$14,$L8=Admin!$B$16,$L8=Admin!$B$17,$L8=Admin!$B$18,$L8=Admin!$B$19,$L8=Admin!$B$21,$L8=Admin!$B$22,$L8=Admin!$B$24,$L8=Admin!$B$25,$L8=Admin!$B$26,$L8=Admin!$B$27)=TRUE,WORKDAY($L8,-1),IF(OR($L8=Admin!$B$7,$L8=Admin!$B$12,$L8=Admin!$B$15,$L8=Admin!$B$20,$L8=Admin!$B$23,$L8=Admin!$B$28)=TRUE,WORKDAY($L8,-2),$L8)),"""")"
Sheet1.Range("$N$" & x) = "=IF($H8=""No"",IF($B8="""","""",WORKDAY($M8,10)),"""")"
Sheet1.Range("$O$" & x) = "=IF($H8=""No"",IF(OR($N8=Admin!$B$5,$N8=Admin!$B$6,$N8=Admin!$B$8,$N8=Admin!$B$9,$N8=Admin!$B$10,$N8=Admin!$B$11,$N8=Admin!$B$13,$N8=Admin!$B$14,$N8=Admin!$B$16,$N8=Admin!$B$17,$N8=Admin!$B$18,$N8=Admin!$B$19,$N8=Admin!$B$21,$N8=Admin!$B$22,$N8=Admin!$B$24,$N8=Admin!$B$25,$N8=Admin!$B$26,$N8=Admin!$B$27)=TRUE,WORKDAY($N8,-1),IF(OR($N8=Admin!$B$7,$N8=Admin!$B$12,$N8=Admin!$B$15,$N8=Admin!$B$20,$N8=Admin!$B$23,$N8=Admin!$B$28)=TRUE,WORKDAY($N8,-2),$N8)),"""")"
Sheet1.Range("$P$" & x) = "=IF($H8=""No"",IF($B8="""","""",WORKDAY($B8,38)),"""")"
Sheet1.Range("$Q$" & x) = "=IF($H8=""No"",IF(OR($P8=Admin!$B$5,$P8=Admin!$B$6,$P8=Admin!$B$8,$P8=Admin!$B$9,$P8=Admin!$B$10,$P8=Admin!$B$11,$P8=Admin!$B$13,$P8=Admin!$B$14,$P8=Admin!$B$16,$P8=Admin!$B$17,$P8=Admin!$B$18,$P8=Admin!$B$19,$P8=Admin!$B$21,$P8=Admin!$B$22,$P8=Admin!$B$24,$P8=Admin!$B$25,$P8=Admin!$B$26,$P8=Admin!$B$27)=TRUE,WORKDAY($P8,-1),IF(OR($P8=Admin!$B$7,$P8=Admin!$B$12,$P8=Admin!$B$15,$P8=Admin!$B$20,$P8=Admin!$B$23,$P8=Admin!$B$28)=TRUE,WORKDAY($P8,-2),$P8)),"""")"
End If
Next