Timesheet VBA

andycrowh

New Member
Joined
Aug 28, 2022
Messages
3
Platform
  1. Windows
Hi there,

I am currently working on a timesheet and need it to do the below before I can send to colleagues to use:

- Column A reads the date in Column B and shows it as a day =TEXT(B9,"dddd") - what would I add that if the cell in Column B is empty nothing shows
- I have a command button that when clicked I want A1:G64 to save as PDF and ask the user where they would like it saved, the name of the PDF file needs to be "B5 Timesheet D7 to F7"

When users fill out the Userform it places a From and To date in the spreadsheet, I want Column B from B9 to populate all dates from the from date to the to date.

Please help
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
hi,
something like this maybe

VBA Code:
    Dim FromDate        As Date, ToDate As Date
    Dim NoDays          As Long
   
    FromDate = DateValue(Me.TextBox1.Value)
    ToDate = DateValue(Me.TextBox2.Value)

    NoDays = ToDate - FromDate + 1
   
    With Range("B9")
        .Value = FromDate
        .Resize(NoDays).DataSeries Rowcol:=xlColumns, Type:=xlChronological, _
                                   Date:=xlDay, Step:=1, Stop:=ToDate, Trend:=False
    End With

Adapt code to meet specific project need as required

Dave
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,217
Members
452,619
Latest member
Shiv1198

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top