create template

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

AQWE2.PNG29076215a--2-.xlsm
ADRIANA PACCOUNTING ASSISTANTAsked:
Who is Participating?

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

x
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?
0
ADRIANA PACCOUNTING ASSISTANTAuthor Commented:
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
0
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")
    Sheets("Template").Range("A1:AC200").Copy
    
    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))
    'Mon
    Cells(rowNo, ToColletter(lastCol + extraRow)) = NextMonday(lastDate)
    'Tue
    Cells(rowNo, ToColletter(lastCol + extraRow + 4)) = NextMonday(lastDate) + 1
    'Wed
    Cells(rowNo, ToColletter(lastCol + extraRow + 8)) = NextMonday(lastDate) + 2
    'Thu
    Cells(rowNo, ToColletter(lastCol + extraRow + 12)) = NextMonday(lastDate) + 3
    'Fri
    Cells(rowNo, ToColletter(lastCol + extraRow + 16)) = NextMonday(lastDate) + 4
    'Sat
    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
29076215a--2-_b.xlsm
1

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!

ADRIANA PACCOUNTING ASSISTANTAuthor Commented:
Ryan Chong Thanks for the great Job !

How i run the code to  create the template ?
0
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.

Untitled1.png
1
ADRIANA PACCOUNTING ASSISTANTAuthor Commented:
Great Job Expert
0
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.