Please refer to the pictures for clarity. I am making a scheduling tool that will map the process times for each day of the week for 4 weeks. The issue I am having is the code I currently have inserts a column for, this example, Monday on week 1. Obviously, this column runs down the following week 2, 3 and 4, which is fine. However, what I would like is when I start a process on monday of week two, the code could see a column is blank, and instead of inserting a new column it just utilizes the previously created column from week 1. For more clarity, week 1 encompasses rows 10-31, and week 2 encompasses rows 41-62.
'''Week 2 Tuesday Start'''
For i = 1 To myWorksheet.Cells(36, myWorksheet.Range("TuesdayStarts").Column)
myFirstColumnT = myWorksheet.Cells.Find( _
What:="TS", _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
myLastColumnT = myWorksheet.Cells.Find( _
What:="TE", _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
For newcol = myLastColumnT To (myFirstColumnT + 1) Step -100000000
myWorksheet.Columns(newcol).Insert CopyOrigin:=xlFormatFromRightOrBelow
Sheets("Templates").Range("A2:A7").Copy
myWorksheet.Cells(41, newcol).PasteSpecial
next newcol
VBA Code:
'''Week 1 tuesday start'''
For i = 1 To myWorksheet.Cells(5, myWorksheet.Range("TuesdayStarts").Column)
myFirstColumnT = myWorksheet.Cells.Find( _
What:="TS", _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
myLastColumnT = myWorksheet.Cells.Find( _
What:="TE", _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
For newcol = myLastColumnT To (myFirstColumnT + 1) Step -100000000
myWorksheet.Columns(newcol).Insert CopyOrigin:=xlFormatFromRightOrBelow
Sheets("Templates").Range("A2:A7").Copy
myWorksheet.Cells(10, newcol).PasteSpecial
Sheets("Templates").Range("H2:H5").Copy
myWorksheet.Cells(41, newcol).PasteSpecial
Next newcol
myFirstColumnW = myWorksheet.Cells.Find( _
What:="WfS", _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
myLastColumnW = myWorksheet.Cells.Find( _
What:="WfE", _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
For newcol = myLastColumnW To (myFirstColumnW + 1) Step -100000000
myWorksheet.Columns(newcol).Insert CopyOrigin:=xlFormatFromRightOrBelow
Sheets("Templates").Range("B2:B16").Copy
myWorksheet.Cells(10, newcol).PasteSpecial
next newcol
VBA Code:
For i = 1 To myWorksheet.Cells(36, myWorksheet.Range("TuesdayStarts").Column)
myFirstColumnT = myWorksheet.Cells.Find( _
What:="TS", _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
myLastColumnT = myWorksheet.Cells.Find( _
What:="TE", _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
For newcol = myLastColumnT To (myFirstColumnT + 1) Step -100000000
myWorksheet.Columns(newcol).Insert CopyOrigin:=xlFormatFromRightOrBelow
Sheets("Templates").Range("A2:A7").Copy
myWorksheet.Cells(41, newcol).PasteSpecial
next newcol