+ Reply to Thread
Results 1 to 3 of 3

Userform Textbox Date - Subtract Weekend

Hybrid View

Nu2Java Userform Textbox Date -... 07-12-2012, 02:22 PM
rvasquez Re: Userform Textbox Date -... 07-12-2012, 03:27 PM
Nu2Java Re: Userform Textbox Date -... 07-12-2012, 05:14 PM
  1. #1
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Userform Textbox Date - Subtract Weekend

    Hello,

    I have a userform that I use to run some data for the previous day which is simple enough for me to use on UserForm_Initialize()

    Me.txtDate = Date - 1
    Is there an easy way to format it so if the form runs on Monday, it subtracts the weekend so it enters Friday's date ?

    Thanks for any help!

  2. #2
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: Userform Textbox Date - Subtract Weekend

    Hello there try this

    If VBA.Format(VBA.Date, "ddd") = "Mon" Then 'if today's date is monday then
        Me.txtdate = VBA.Date - 3   'txtdate is equal to friday's date
    Else
        Me.txtdate = VBA.Date - 1   'else it's equal to today's date
    End If

  3. #3
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Re: Userform Textbox Date - Subtract Weekend

    rvasquez,

    This works like a charm... just what I needed. Thanks very much for your time and help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1