Results 1 to 13 of 13
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Days without (2000 sr-1)

    is possible to have into combobox cboDate inested all days of the year only the complete list of days without Saturday Sunday...

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Days without (2000 sr-1)

    Try this, in the ResetDate procedure:

    Case "01-GIORNALIERA"
    For DAYINDEX = 1 To Day(DateSerial(cboAnno.Value, MONTHINDEX + 1, 0))
    d = DateSerial(cboAnno.Value, MONTHINDEX, DAYINDEX)
    If Weekday(d, vbMonday) < 6 Then
    cboDate.AddItem Format(d, "Short Date")
    End If
    Next DAYINDEX

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Days without (2000 sr-1)

    WIZARD!

  4. #4
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Days without (2000 sr-1)

    YEAH!!!
    Is possible when i insert into tbox1 of this userform the date, if is a existis a date of the year without saturday and sunday. (if is simple to lookup the date into procedure, you have now modified). Ihave used an old code to cotroll the correct entry of date but no control if the date insetted is into range of work days.

    This userform is called from the userform attached into this first post with:

    Private Sub CommandButton1_Click()
    Dim I As Integer
    Dim J As Integer

    If ListBox1.ListCount - 1 < 0 Then
    MsgBox "ATTENZIONE: SELEZIONARE UN CONTROLLO!", vbExclamation
    'Else
    Exit Sub
    End If
    'Sheets("CODICI").Range("H2:J500").ClearContents
    'COPIA SK
    RIGA = 1
    For I = 0 To ListBox1.ListCount - 1
    If ListBox1.Selected(I) = False Then
    RIGA = RIGA + 1
    For J = 0 To ListBox1.ColumnCount - 1
    Sheets("CODICI").Cells(RIGA, 9 + J) = Left((ListBox1.List(I, J)), 7)
    Next
    End If
    Next I
    'COPIA SPORTELLI
    RIGA1 = 1
    If ListBox2.ListCount - 1 < 0 Then
    MsgBox "ATTENZIONE: SELEZIONARE SPORTELLI!", vbExclamation
    'Else
    Exit Sub
    End If
    For I = 0 To ListBox2.ListCount - 1
    If ListBox2.Selected(I) = False Then
    RIGA1 = RIGA1 + 1
    For J = 0 To ListBox2.ColumnCount - 1
    Sheets("CODICI").Cells(RIGA1, 8 + J) = Left((ListBox2.List(I, J)), 4)
    Next
    End If
    Next I


    DATA_MATRICOLA.Show

    Call cmdElabora_Click

    ListBox1.Clear
    ListBox2.Clear

    Me.Hide

    End Sub

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Days without (2000 sr-1)

    I'm sorry, I don't understand your question (I don't even know if you're asking a question)

  6. #6
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Days without (2000 sr-1)

    Simple:-)
    When i insert into userform textbox1 (in attached userform DATA_MATRICOLA) controll the correct entry of date in this format gg/mm/yyyy and controll always if the date entered not is a sunday or saturday from the day of the year...
    I tnink, to simplify, you cane use the procedure above to controll the work days:
    Case "01-GIORNALIERA"
    For DAYINDEX = 1 To Day(DateSerial(cboAnno.Value, MONTHINDEX + 1, 0))
    d = DateSerial(cboAnno.Value, MONTHINDEX, DAYINDEX)
    If Weekday(d, vbMonday) < 6 Then
    cboDate.AddItem Format(d, "Short Date")
    End If
    Next DAYINDEX

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Days without (2000 sr-1)

    You can use the Before Update event of the text box:

    Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
    If Not IsDate(Me.TextBox1) Then
    MsgBox "Please enter a valid date.", vbInformation
    Cancel = True
    ElseIf Weekday(Me.TextBox1, vbMonday) > 5 Then
    MsgBox "The date you entered is a weekend day!", vbInformation
    Cancel = True
    End If
    End Sub

    (Translate the error messages into Italian)

  8. #8
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Days without (2000 sr-1)

    they are allowed to me of change a part of your code wath you tnik?


    Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
    Dim DATA As Date
    DATA = Me.TextBox1
    If Not Me.TextBox1 = Format(DATA, "DD/MM/YYYY") Then
    MsgBox "Please enter a valid date.", vbInformation
    Me.TextBox1 = ""
    Me.TextBox1.SetFocus
    ElseIf Weekday(Me.TextBox1, vbMonday) > 5 Then
    MsgBox "LA DATA INSERITA E' UN GIORNO FESTIVO!", vbInformation
    Me.TextBox1 = ""
    Me.TextBox1.SetFocus
    End If
    End Sub
    (Note: why when i insert a avlue into text box the character are formated underline and after i go on a other txbox the underline not disappear?)

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Days without (2000 sr-1)

    Looks OK.

    I don't know what causes the underline. If you don't like it, delete the text box and create a new one with the same name.

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Days without (2000 sr-1)

    You must use the Cancel argument, as in my example:

    Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
    Dim DATA As Date
    If Not Me.TextBox1 = Format(DATA, "DD/MM/YYYY") Then
    MsgBox "Please enter a valid date.", vbInformation
    Cancel = True
    Exit Sub
    ElseIf Weekday(Me.TextBox1, vbMonday) > 5 Then
    MsgBox "LA DATA INSERITA E' UN GIORNO FESTIVO!", vbInformation
    Cancel = True
    Exit Sub
    End If
    DATA = Me.TextBox1
    End Sub

  11. #11
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Days without (2000 sr-1)

    tks for note, very happy, you send me "Look ok" , with you all is possible:-)
    ummmmm why after the error appear the cursor not go into tbox1 for new entry of date? I have set infocus in txbox property but not work.... boh?!

    AND....

    Is possible to include into a controll of workday also this range (sheet CODICI range K2:K13) are the internation holiday into world and italian holidays...

    01/01/2005
    06/01/2005
    27/03/2005
    28/03/2005
    25/04/2005
    01/05/2005
    02/06/2005
    15/08/2005
    01/11/2005
    08/12/2005
    25/12/2005
    26/12/2005

  12. #12
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Days without (2000 sr-1)

    Hi Hans, sorry for this...
    During you reply my last post i have update my last msg Post: 548,006, see now, please.
    Sorry.

  13. #13
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Days without (2000 sr-1)

    You already have many examples of code that uses the Find method to see if a value occurs in a range. You can use this to test if DATA occurs in K2:K13 on the CODICI sheet.

Posting Permissions

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