Jump to content
Fórum Script Brasil
  • 0

Erro aparentemente sem causa alguma


Question

Function validaData() As Boolean

    Call optimizacaoEntrada 'módulo sub_optimizadoras
    
    Dim dia As Integer
    Dim dd As Integer
    Dim barra As Integer
    
    Select Case Worksheets("planVig").Range("$B$8").Value
        Case ""
            Beep
            MsgBox "DIGITE UMA DATA VÁLIDA!", vbCritical, "Data inválida!"
            validaData = False
            Exit Function
        
        Case Else
          If Not IsDate(Worksheets("planVig").Range("$B$8").Value) Then
            Beep
            'MsgBox Len(Range("$B$8"))
            Range("$B$7").Activate
            Beep
            MsgBox "DIGITE UMA DATA VÁLIDA!", vbCritical, "Data inválida!"
            Call optimizacaoSaida 'sub_optimizadoras
            validaData = False
            Exit Function
          Else
            barra = InStr(1, Worksheets("planVig").Range("$B$8").Value, "/")
            dia = Day(Worksheets("planVig").Range("$B$8").Value)
            dd = Left(Worksheets("planVig").Range("$B$8").Value, barra - 1)
            If dd <> dia Then
                Beep
                Range("$B$8").Activate
                Beep
                MsgBox "DIGITE UMA DATA VÁLIDA!", vbCritical, "Data inválida!"
                Call optimizacaoSaida 'sub_optimizadoras
                validaData = False
                Exit Function
            Else
                Worksheets("planVig").Range("$A$7").Value = Day(Worksheets("planVig").Range("$B$8").Value)
                Worksheets("planVig").Range("$B$7").Activate
                Call optimizacaoSaida 'módulo sub_optimizadoras
                Exit Function
            End If
          End If
    End Select
End Function

 

2_erroVBA_Excel365_Sistema_Win10_64.png

1_erroVBA_Excel365_Sistema_Win10_64.png

Link to post
Share on other sites

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      149151
    • Total Posts
      645419
×
×
  • Create New...