Função Hora. Ajuda!

Guijeta

New Member
Joined
Oct 4, 2007
Messages
16
Obrigado por ver a minha questao!
Por que quando coloco a Funcao Hora dentro de uma sub o sistema nao reconhece como uma funcao valida?
Segue exemplo

Code:
Sub Cumprimento()
    If Hora < 0.5 Then MsgBox "Bom dia"
End Sub

Hora sempre aparece como vazio!
Obrigado
 
Last edited by a moderator:

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
¿Ésto le ayuda?
Code:
Sub foo()
    Dim strMensaje As String
    If Time < 0.5 Then
        strMensaje = "buenos días"
    ElseIf Time < 0.75 Then
        strMensaje = "buenas tardes"
    Else
        strMensaje = "buenas noches"
    End If
 
    MsgBox strMensaje, vbInformation, "Hola"
 
End Sub
 
Upvote 0
¿Cuál versión está usando?

EDIT --¿Y estamos hablando de VBA, y no la hoja, verdad?
 
Last edited:
Upvote 0
Hola Greg,
Yo uso una versión 2007 del Office, que debe tener algo de diferente porque la misma macro en un 2003 sale bién...
gracias
 
Upvote 0
Intento que comprueba debajo de Tools> Referencias… en el redactor de VBA.
 
Upvote 0
Debe de funcionar. Me funciona en 2007. ¿Qué resultados da esto?

Code:
Sub foo2()
    Dim strMensaje As String, _
        dblTime As Double
        
    dblTime = Now - Date
    
    MsgBox Format(dblTime, "hh:mm:ss")
    
    If dblTime < 0.5 Then
        strMensaje = "buenos días"
    ElseIf dblTime < 0.75 Then
        strMensaje = "buenas tardes"
    Else
        strMensaje = "buenas noches"
    End If
 
    MsgBox strMensaje, vbInformation, "Hola"
 
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,970
Messages
6,175,703
Members
452,667
Latest member
vanessavalentino83

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