I am trying to loop thru a range of cells and place a formula into each cell that has absolute and relevant values in it. the Starting range is $V$23:$V$147 to the last column.
In order to find the last column i have to find the number of days between 2 dates from another sheet.
i am finding looping a mystery as much as i have read tutorials and classes on it.
The formula that needs to go in each cell is
=IF($N23>V$22,"",
IF(AND(V$22>TODAY(),V179="T"),SUMIFS(Agent_HC_Summary!$S:$S,Agent_HC_Summary!$B:$B,GSM_Daily_Summary!$D23,Agent_HC_Summary!$C:$C,GSM_Daily_Summary!V$22)-(SUMIFS(Agent_HC_Summary!$S:$S,Agent_HC_Summary!$B:$B,GSM_Daily_Summary!$D23,Agent_HC_Summary!$C:$C,GSM_Daily_Summary!V$22)*XLOOKUP(V$22,Agent_HC_Summary!$C:$C,Agent_HC_Summary!$O:$O)),
IF(AND(V$22>TODAY(),V179="N"),SUMIFS(Agent_HC_Summary!$S:$S,Agent_HC_Summary!$B:$B,GSM_Daily_Summary!$D23,Agent_HC_Summary!$C:$C,GSM_Daily_Summary!V$22)-(SUMIFS(Agent_HC_Summary!$S:$S,Agent_HC_Summary!$B:$B,GSM_Daily_Summary!$D23,Agent_HC_Summary!$C:$C,GSM_Daily_Summary!V$22)*XLOOKUP(V$22,Agent_HC_Summary!$C:$C,Agent_HC_Summary!$N:$N)),
IF(AND(V$22>TODAY(),V179="P"),SUMIFS(Agent_HC_Summary!$S:$S,Agent_HC_Summary!$B:$B,GSM_Daily_Summary!$D23,Agent_HC_Summary!$C:$C,GSM_Daily_Summary!V$22)-(SUMIFS(Agent_HC_Summary!$S:$S,Agent_HC_Summary!$B:$B,GSM_Daily_Summary!$D23,Agent_HC_Summary!$C:$C,GSM_Daily_Summary!V$22)*XLOOKUP(V$22,Agent_HC_Summary!$C:$C,Agent_HC_Summary!$M:$M)),
SUMIFS(Agent_HC_Summary!$S:$S,Agent_HC_Summary!$B:$B,GSM_Daily_Summary!$D23,Agent_HC_Summary!$C:$C,GSM_Daily_Summary!V$22)))))
Please note though the values in the formula will change based on what cell its in
can someone please assist me or tell me where to start
In order to find the last column i have to find the number of days between 2 dates from another sheet.
i am finding looping a mystery as much as i have read tutorials and classes on it.
The formula that needs to go in each cell is
=IF($N23>V$22,"",
IF(AND(V$22>TODAY(),V179="T"),SUMIFS(Agent_HC_Summary!$S:$S,Agent_HC_Summary!$B:$B,GSM_Daily_Summary!$D23,Agent_HC_Summary!$C:$C,GSM_Daily_Summary!V$22)-(SUMIFS(Agent_HC_Summary!$S:$S,Agent_HC_Summary!$B:$B,GSM_Daily_Summary!$D23,Agent_HC_Summary!$C:$C,GSM_Daily_Summary!V$22)*XLOOKUP(V$22,Agent_HC_Summary!$C:$C,Agent_HC_Summary!$O:$O)),
IF(AND(V$22>TODAY(),V179="N"),SUMIFS(Agent_HC_Summary!$S:$S,Agent_HC_Summary!$B:$B,GSM_Daily_Summary!$D23,Agent_HC_Summary!$C:$C,GSM_Daily_Summary!V$22)-(SUMIFS(Agent_HC_Summary!$S:$S,Agent_HC_Summary!$B:$B,GSM_Daily_Summary!$D23,Agent_HC_Summary!$C:$C,GSM_Daily_Summary!V$22)*XLOOKUP(V$22,Agent_HC_Summary!$C:$C,Agent_HC_Summary!$N:$N)),
IF(AND(V$22>TODAY(),V179="P"),SUMIFS(Agent_HC_Summary!$S:$S,Agent_HC_Summary!$B:$B,GSM_Daily_Summary!$D23,Agent_HC_Summary!$C:$C,GSM_Daily_Summary!V$22)-(SUMIFS(Agent_HC_Summary!$S:$S,Agent_HC_Summary!$B:$B,GSM_Daily_Summary!$D23,Agent_HC_Summary!$C:$C,GSM_Daily_Summary!V$22)*XLOOKUP(V$22,Agent_HC_Summary!$C:$C,Agent_HC_Summary!$M:$M)),
SUMIFS(Agent_HC_Summary!$S:$S,Agent_HC_Summary!$B:$B,GSM_Daily_Summary!$D23,Agent_HC_Summary!$C:$C,GSM_Daily_Summary!V$22)))))
Please note though the values in the formula will change based on what cell its in
can someone please assist me or tell me where to start
VBA Code:
Sub GSM_Daily_Sub()
Dim wb As Workbook, ws As Worksheet, datews As Worksheet, lstcol As Long, lstr As Long, j As Long, i As Long
Set ws = ThisWorkbook.Sheets("GSM_Daily_Summary")
Set datews = ThisWorkbook.Sheets("Agent_HC_Input")
'finding out the amount of days between the 2 Dates on Agent HC Input sheet
Difference_Format = "d"
Date1 = CDate(datews.Range("M2"))
Date2 = CDate(datews.Range("N2"))
'sets the last column equal to the amount of days between the 2 dates entered
lstcol = DateDiff(Difference_Format, Date1, Date2)
'set last row variable to row 147
lstr = 147
ws.Activate
' to loop through each column and then go to the nextr row
For i = 23 To lstr ' this starts on row 23
For j = 22 To lstcol ' this starts on column 22 which is column V
Next j
Next i
End Sub