I'm trying to populate a row of cells in a Calendar kind of way, where I skip the 7th Cell, that is the Sunday. The loop should continue writting values than on Monday or the 8th Cell. And So on for every week. The ranges of the cells varies depending on the given number of Days.
I tried setting my skipping condition using MOD for every 7th Day with the Loop value. MOD(number, divisor) = 0
.
If that checks out, no values should be added on the 7th cell but on the 8th.
The problem comes after the first sunday . My LoopValue is one "value" behind because of the offset.
When it comes to the second sunday the condition is already one step behind, skipping the cells not on Sunday (14th day) but on Monday (16th) Day
I then tried "hard coding" the condition, to skip every 7,13,19,25,31,37th Day.. but it worked until the 25th Day.
Sub t1_Sunday4()
Dim in1Days, in2Value, jj1 As Integer
Dim os_skip, os_New As Integer
Dim x_ShortCondt As Boolean
os_New = 1
in1Days = Range("A3")
in2Value = Range("B3")
Sub t1()
Dim in1Days, in2Value, jj1 As Integer
Dim os_skip, os_New As Integer
Dim x_ShortCondt As Boolean
os_New = 1
in1Days = Range("A3")
in2Value = Range("B3")
x_ShortCondt = False
For jj1 = 1 To in1Days
Cells(5, 5 + jj1) = jj1 ' # Iteration
If x_ShortCondt = True Then
'MOD CONDITION
If (jj1 Mod 7) = 0 Then ' Condition for every 7th Day
os_skip = jj1 / 7
os_New = jj1 + os_skip 'Off Set Cell number
End If
Else
'HARD CODING THE CONDITION
If jj1 = 7 Or jj1 = 13 Or jj1 = 19 Or jj1 = 25 _
Or jj1 = 31 Or jj1 = 37 Or jj1 = 37 Or jj1 = 43 _
Or jj1 = 49 Then
os_skip = jj1 / 7
os_New = jj1 + os_skip
End If
End If
'POPULATE CELLS
Cells(3, 5 + os_New) = in2Value ' Value to add in cell
' CONTROL LOOP AND OFFSET VALUES
Cells(6, 5 + os_New) = jj1 ' Iteration for said Value after Offset
Cells(7, 5 + os_New) = os_New ' Value for Offset
os_New = os_New + 1
Next jj1
End Sub