I have been trying to search how to do this and have not come across anything that helps me with what I am trying to accomplish. I have seen select statements with multiple conditions, but not multiple actions. I am trying to replicate a calculation based on if the action is done daily. I am trying to calculate the dates of the current week on a scheduling tool so that they get stored as unique jobs for the date specifically (kind of like a historical repository which will feed my schedule each week when I hit the command button). Since some activities are daily I want them to appear in all of the days on my schedule. Here is the code I have, but its not giving me separate jobs for the daily portion. Marked the portion I am referring to in blue. Thank you so much in advance !!!
Code:
Sub FreqCalc()
'macro to loop through the recurrent jobs and create new jobs on master job trail based on their specified frequency
Dim NameRange As Range
Dim CompleteUniqueName As String
Dim Concatenater As Object
Dim UniqueID As Variant
Set Concatenater = CreateObject("scripting.dictionary")
With Sheets("Recurrent Job Trail")
For Each NameRange In .Range("A2", .Range("A" & Rows.Count).End(xlUp))
CompleteUniqueName = NameRange.Value & " - " & NameRange.Offset(, 3).Value & " ("
Select Case NameRange.Offset(, 19).Value
[COLOR=#0000ff] Case "Diario"[/COLOR]
[COLOR=#0000ff] CompleteUniqueName = CompleteUniqueName & (Date - Weekday(Date, vbMonday) + 1) & ")"[/COLOR]
[COLOR=#0000ff] CompleteUniqueName = CompleteUniqueName & (Date - Weekday(Date, vbMonday) + 2) & ")"[/COLOR]
[COLOR=#0000ff] CompleteUniqueName = CompleteUniqueName & (Date - Weekday(Date, vbMonday) + 3) & ")"[/COLOR]
[COLOR=#0000ff] CompleteUniqueName = CompleteUniqueName & (Date - Weekday(Date, vbMonday) + 4) & ")"[/COLOR]
[COLOR=#0000ff] CompleteUniqueName = CompleteUniqueName & (Date - Weekday(Date, vbMonday) + 5) & ")"[/COLOR]
Case "Semanal"
CompleteUniqueName = CompleteUniqueName & "Week of " & (Date - Weekday(Date, vbMonday) + 1) & ")"
Case "Mensual"
CompleteUniqueName = CompleteUniqueName & Format(Date, "mmm/yyyy") & ")"
Case "Trimestral"
CompleteUniqueName = CompleteUniqueName & "Trimester starting " & Format(Date, "yyyy") & ")"
Case "Anual"
CompleteUniqueName = CompleteUniqueName & Format(Date, "yyyy") & ")"
End Select
Set Concatenater(CompleteUniqueName) = NameRange
Next NameRange
End With
With Sheets("Master Job Trail")
For Each NameRange In .Range("A2", .Range("A" & Rows.Count).End(xlUp))
If Concatenater.Exists(NameRange.Value) Then Concatenater.Remove NameRange.Value
Next NameRange
For Each UniqueID In Concatenater.Keys
With .Range("A" & Rows.Count).End(xlUp).Offset(1)
.Value = UniqueID
Concatenater(UniqueID).Resize(, 19).Copy
.Offset(, 1).PasteSpecial xlPasteValues
End With
Next UniqueID
End With
End Sub
Last edited by a moderator: