Hi All,
I built our weekly/daily time sheets some years ago in Excel using mostly formulas to do the calculations. This worked great, but since I started to learn more about vba and userforms I am busy streamlining it to use userform inputs and vba to send the information to the relevant sheets.
I have a summary sheet (shSummary) and then daily sheets (shMon; shTue; shWed; etc) On the summary sheet there is a date (WkStartDate) for the begining of the week and I calculate the end of the week with a basic formula.
My userform is for the daily sheets. It have textboxes for the user inputs which is then sent to the sheet with vba. In the userform I have a Label (lDate) that I want to populate the day's date and (lDay) the day of the week.
When I call the userform, I was thinking of using the Select Case statement to calculate the date according to the active sheet. For example
if I'm in shMon then lDate = WkStartDate
if I'm in shTue then lDate = WkStartDate + 1
etc.
I have absolutely no idea how to work with the select case statement and you will see that in my "BallsUp" of code.
any and all suggestions will be highly appreciated.
I built our weekly/daily time sheets some years ago in Excel using mostly formulas to do the calculations. This worked great, but since I started to learn more about vba and userforms I am busy streamlining it to use userform inputs and vba to send the information to the relevant sheets.
I have a summary sheet (shSummary) and then daily sheets (shMon; shTue; shWed; etc) On the summary sheet there is a date (WkStartDate) for the begining of the week and I calculate the end of the week with a basic formula.
My userform is for the daily sheets. It have textboxes for the user inputs which is then sent to the sheet with vba. In the userform I have a Label (lDate) that I want to populate the day's date and (lDay) the day of the week.
When I call the userform, I was thinking of using the Select Case statement to calculate the date according to the active sheet. For example
if I'm in shMon then lDate = WkStartDate
if I'm in shTue then lDate = WkStartDate + 1
etc.
I have absolutely no idea how to work with the select case statement and you will see that in my "BallsUp" of code.
Code:
Private Sub UserForm_Initialize()
'PURPOSE: Initialize the Resource UserForm
'Show the date and day at the top of the UserForm
Dim sh As Worksheet
Dim shAct As Worksheet
Dim d As Date
Set sh = shSummary
Set shAct = ActiveSheet
d = CDate(sh.Range("Y7").Value)
Select Case d
Case shAct = shMon
Me.LDate.Value = Format(CStr(d + 1), "dd MMMM YYYY")
Case shAct = shTue
' d 1
' Case shAct = shWed
' d 2
' Case shAct = shThu
' d 3
' Case shAct = shFri
' d 4
' Case shAct = shSat
' d 5
' Case shAct = shsum
' d 6
End Select
End Sub
any and all suggestions will be highly appreciated.