The code below works fine but i'm guessing there will be a way to use 1 loop
instead of 3. If, say, i could have range names and symbol character names in
a 3 x 2 array and loop through the array.. ?? (i've tried and failed)
Sub PopulateTimeChart()
Dim TimeChart As Range ' grid populated with symbols to show timing of
various events
Dim RefurbDate As Range ' column range populated w/ years: 2012, 2020, etc
Dim ReplaceDate As Range ' ditto
Dim EnhanceDate As Range 'ditto
Dim EndDates As Range 'ditto
Dim DateHeaders As Range 'Timechart column headers populated with years:
2009, 2101, etc (sequentially, step 1 year)
Dim cl_1 As Range, cl_2 As Range, cl_3 As Range
Dim YearsRemaining As Integer, Period As Integer, i As Integer
Application.ScreenUpdating = False
Set TimeChart = Range("TimeChart")
Set RefurbDate = Range("RefurbDate")
Set ReplaceDate = Range("ReplaceDate")
Set EnhanceDate = Range("EnhanceDate")
Set EndDates = Range("EndDate")
Set DateHeaders = TimeChart.Offset(-1).Resize(1)
TimeChart.ClearContents
For Each cl_1 In EnhanceDate
If Not Val(cl_1) = 0 Then
For Each cl_2 In DateHeaders
If cl_2 = cl_1 Then
Set cl_3 = Intersect(cl_1.EntireRow, cl_2.EntireColumn)
Period = Val(cl_1.Offset(, 1)) 'may be zero
YearsRemaining = Intersect(cl_1.EntireRow, EndDates) -
cl_2
If Period = 0 Then
cl_3.Value = "u" 'diamond symbol
Else
For i = 0 To YearsRemaining Step Period
cl_3.Offset(, i).Value = "u" 'diamond symbol
Next i
End If
End If
Next cl_2
End If
Next cl_1
For Each cl_1 In RefurbDate
If Not Val(cl_1) = 0 Then
For Each cl_2 In DateHeaders
If cl_2 = cl_1 Then
Set cl_3 = Intersect(cl_1.EntireRow, cl_2.EntireColumn)
Period = Val(cl_1.Offset(, 1)) 'may be zero
YearsRemaining = Intersect(cl_1.EntireRow, EndDates) -
cl_2
If Period = 0 Then
cl_3.Value = "¬" 'star symbol
Else
For i = 0 To YearsRemaining Step Period
cl_3.Offset(, i).Value = "¬" 'star symbol
Next i
End If
End If
Next cl_2
End If
Next cl_1
For Each cl_1 In ReplaceDate
If Not Val(cl_1) = 0 Then
For Each cl_2 In DateHeaders
If cl_2 = cl_1 Then
Set cl_3 = Intersect(cl_1.EntireRow, cl_2.EntireColumn)
Period = Val(cl_1.Offset(, 1)) 'may be zero
YearsRemaining = Intersect(cl_1.EntireRow, EndDates) -
cl_2
If Period = 0 Then
cl_3.Value = "l" 'bullet symbol
Else
For i = 0 To YearsRemaining Step Period
cl_3.Offset(, i).Value = "l" 'bullet symbol
Next i
End If
End If
Next cl_2
End If
Next cl_1
End Sub