create template

button to create the  Week date  am/pm and relative spaces

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
button to create the  Week date  am/pm and relative spaces
can you explain further how you wish these columns to be generated?

do you only need to create for 1 week (append from last used column)?
OR the whole series from col C to col DU?

any logic to share with?
Ryan Chong

append from last used column

need add one week as it needed ( when finish week 1 then goes to create week 2)

is an 31 sequence
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
to make it easier, I have created a template to be used, and then using codes below:

Sub CreateTemplate()
    Dim lastCol As Integer, rowNo As Integer, extraRow As Integer
    Dim lastDate As String
    rowNo = 5
    extraRow = 3
    lastCol = ActiveSheet.Cells(rowNo, ActiveSheet.Columns.Count).End(xlToLeft).Column
    Sheets("Template").Range("A1:AC200").Copy ActiveSheet.Range(ToColletter(lastCol + extraRow) & "1")
    ActiveSheet.Range(ToColletter(lastCol + extraRow) & "1").PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    'Default to first week
    If lastCol < 9 Then
        'need handle this?
    End If
    lastDate = Cells(rowNo, ToColletter(lastCol - 8))
    Cells(rowNo, ToColletter(lastCol + extraRow)) = NextMonday(lastDate)
    Cells(rowNo, ToColletter(lastCol + extraRow + 4)) = NextMonday(lastDate) + 1
    Cells(rowNo, ToColletter(lastCol + extraRow + 8)) = NextMonday(lastDate) + 2
    Cells(rowNo, ToColletter(lastCol + extraRow + 12)) = NextMonday(lastDate) + 3
    Cells(rowNo, ToColletter(lastCol + extraRow + 16)) = NextMonday(lastDate) + 4
    Cells(rowNo, ToColletter(lastCol + extraRow + 20)) = NextMonday(lastDate) + 5
    'Week number
    Cells(rowNo - 1, ToColletter(lastCol + extraRow)) = Format(NextMonday(lastDate), "ww") & "w" & Year(NextMonday(lastDate))
    Cells(rowNo - 1, ToColletter(lastCol + extraRow + 24)) = Cells(rowNo, ToColletter(lastCol + extraRow)) & "T"
End Sub

Public Function ToColletter(ByVal Collet As Integer) As String
    ToColletter = Split(Cells(1, Collet).Address, "$")(1)
End Function

Public Function NextMonday(ByVal v As Date) As Date
    NextMonday = v + (8 - Weekday(v, vbMonday))
End Function

Open in new window

see if this make sense?

this seems not a complete solution but could be good enough for you to populate the "template" you needed

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Ryan Chong Thanks for the great Job !

How i run the code to  create the template ?
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
How i run the code to  create the template ?
you can press Alt + F8 to show the Macro window, and then select the CreateTemplate macro and click Run.

Great Job Expert
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.