carlAlex
3/8/2017 - 11:49 AM

Excel VBA TextBox snippet

Excel VBA TextBox snippet

Private Sub TextBoxLogPeriod_Change()

    Call OnlyNumbers(TextBoxLogPeriod)

End Sub

Private Sub OnlyNumbers(ByRef tTextBox As Control)

    With tTextBox
    
        If Not IsNumeric(.Value) And .Value <> vbNullString Then
    
            MsgBox "FEIL! Skriv tid slik: HHMMHHMM - eks: 11501320"
            
            '.Value = vbNullString
    
        End If
    End With
    
End Sub