I'm having an issue trying to integrate a condition inside a Loop. This condition populates the first 5 cells in a Row (Weekdays) and then skips the next 2 (the Weekend). This goes on depending on the number of the Days.
This happens while reading a various number of rows, with different Days, Values and Start Dates (outer loop? )
The Data should be populated depending on said Start Date.
To solve thi,s I compare the difference in Start Dates from the current data with the previous one, getting the difference in number of Days. Then offset the new Data for those Days in the columns.
My issue is getting to skip the 6th and 7th column/value part.
Thanks in advance.
I tried a related Solution posted from "karma" which works for one single row. But get some errors when trying to loop through all the data (reading all my Data). The error in this case, only one Row gets populated until the very last Column in Excel, ignoring the number of Days as condition, and not itirating through the next rows. And there I'd still need to populate the information depending on the Start Date.
For the first Code missing the skip part :
Sub xt4_LoopDate()
Dim ii1, jj1, osi1, osj1 As Integer
Dim in1Days As Integer, in2Value As Integer
Dim xiStart, in3Datum As Date
Dim xiDiff As Long
Dim jbound As Integer
Range("F3:XFD7").ClearContents
osi1 = 2 'Row
osj1 = 5 'Column
jbound = 5 'Upper Bound
xiStart = Range("C3") 'Start Date
For ii1 = 1 To jbound
in1Days = Range("A" & ii1 + osi1) 'Get Dauer
in2Value = Range("B" & ii1 + osi1) 'Get Leistung
in3Datum = Range("C" & ii1 + osi1) 'Get Start
xiDiff = DateDiff("D", xiStart, in3Datum) 'DifferenceDates
For jj1 = 1 To in1Days 'Loop the Length
Cells(ii1 + osi1, jj1 + osj1 + xiDiff) = in2Value
Next jj1
Next ii1
End Sub
For the Second Code with the Loop Errors, missing the condition to start on a certain date :
Sub LSATURDAY_V1()
Dim in1Days As Integer, in2Value As Integer
Dim osii1, osjj1 As Integer
Dim ii1 As Integer, NumberRows As Integer
Dim i As Integer, f As Integer, s As Integer, oFill As Range
Range("F3:XFD6").ClearContents
osii1 = 2 'Offset Row
osjj1 = 5 'Offset Column
f = 5: s = 2
NumberRows = 2
For ii1 = 1 To NumberRows
in1Days = Range("A" & ii1 + osii1)
in2Value = Range("B" & ii1 + osii1)
Debug.Print "D&L -> "; in1Days & " "; in2Value
Set oFill = Range("F" & ii1 + osii1)
Do
For i = 1 To f
oFill.Value = in2Value
Set oFill = oFill.Offset(0, 1)
'works for one Row -> Range("N3:XFD3")
If Application.CountA(Range("F" & ii1 & ":XFD" & ii1)) = in1Days Then Exit Sub
Next i
Set oFill = oFill.Offset(0, s)
Loop
Next ii1
End Sub