Anzeige
Archiv - Navigation
788to792
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
788to792
788to792
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Select Case+Numeric

Select Case+Numeric
04.08.2006 08:35:49
SteffenS
Guten morgen an alle,
wie kann ich in einer Select Case Abfrage, abfragen ob es sich bei dem Wert um eine Zahl handelt.
Mein Versuch:
Select Case Target.Value
Case IsNumeric(Target.Value) = True
End Select
Funktioniert leider nicht
MFG
Steffen Schmerler

4
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Select Case+Numeric
04.08.2006 08:40:29
Dr.
Hi,
z.B. so:
Select Case IsNumeric(Target.Value)
Case Is = True
MsgBox "Zahl"
Case Is = False
MsgBox "keine Zahl"
End Select
noch eine Frage
04.08.2006 09:08:22
SteffenS
Meine Abfrage sieht im Detail so aus:
Select Case Target.Value
Case "U", "u"
'Target.Value = UCase(Target.Value)
With Target
.Interior.ColorIndex = 5
.Font.ColorIndex = 2
.HorizontalAlignment = xlCenter
End With
Case "S", "s"
Target.Value = UCase(Target.Value)
With Target
.Interior.ColorIndex = 4
.Font.ColorIndex = 1
.HorizontalAlignment = xlCenter
End With
Case "K", "s"
Target.Value = UCase(Target.Value)
With Target
.Interior.ColorIndex = 3
.Font.ColorIndex = 2
.HorizontalAlignment = xlCenter
End With
Case "V", "v"
Target.Value = UCase(Target.Value)
With Target
.Interior.ColorIndex = 6
.Font.ColorIndex = 1
.HorizontalAlignment = xlCenter
End With
Case IsNumeric(Target.Value) = True
'Fehlermeldung
MsgBox ("Der eingebene Wert ist ungültig.")
Target.ClearContents
Case Else
With Target
.Font.ColorIndex = 1
.HorizontalAlignment = xlRight
End With
If Target.Row Mod 2 0 Then
Target.Interior.ColorIndex = xlNone
Else
Target.Interior.ColorIndex = 15
End If
End Select
Wie kann ich das numeric abfragen ohne es beim Select Case zu hinterlegen?
Danke nochmals
Steffen Schmerler
Anzeige
AW: noch eine Frage
04.08.2006 09:35:12
Heiko
Hallo Steffen,
das würde so in der Art machen:

Private Sub Worksheet_Change(ByVal Target As Range)
' Wenn es wirklich, wie hier in meinem Beispiel auf Change reagieren soll dann
' die Events abschalten sonst ist es eine Endlosschleife.
Application.EnableEvents = False
With Target
If IsNumeric(.Value) = False Then
Select Case UCase(Target.Value)
Case "U"
.Value = UCase(Target.Value)
.Interior.ColorIndex = 5
.Font.ColorIndex = 2
.HorizontalAlignment = xlCenter
Case "S"
.Value = UCase(Target.Value)
.Interior.ColorIndex = 4
.Font.ColorIndex = 1
.HorizontalAlignment = xlCenter
Case "K"
.Value = UCase(Target.Value)
.Interior.ColorIndex = 3
.Font.ColorIndex = 2
.HorizontalAlignment = xlCenter
Case "V"
.Value = UCase(Target.Value)
.Interior.ColorIndex = 6
.Font.ColorIndex = 1
.HorizontalAlignment = xlCenter
Case Else
.Font.ColorIndex = 1
.HorizontalAlignment = xlRight
If .Row Mod 2 <> 0 Then
.Interior.ColorIndex = xlNone
Else
.Interior.ColorIndex = 15
End If
End Select
Else
MsgBox ("Der eingebene Wert ist ungültig.")
.ClearContents
End If
End With
Application.EnableEvents = True
End Sub

Gruß Heiko
PS: Rückmeldung wäre nett !
Anzeige
Nachtrag
04.08.2006 09:39:38
Heiko
Hallo,
na wenn schon dann richtig ;-)

Private Sub Worksheet_Change(ByVal Target As Range)
' Wenn es wirklich, wie hier in meinem Beispiel auf Change reagieren soll dann
' die Events abschalten sonst ist es eine Endlosschleife.
Application.EnableEvents = False
With Target
If IsNumeric(.Value) = False Then
Select Case UCase(.Value)
Case "U"
.Value = UCase(.Value)
.Interior.ColorIndex = 5
.Font.ColorIndex = 2
.HorizontalAlignment = xlCenter
Case "S"
.Value = UCase(.Value)
.Interior.ColorIndex = 4
.Font.ColorIndex = 1
.HorizontalAlignment = xlCenter
Case "K"
.Value = UCase(.Value)
.Interior.ColorIndex = 3
.Font.ColorIndex = 2
.HorizontalAlignment = xlCenter
Case "V"
.Value = UCase(.Value)
.Interior.ColorIndex = 6
.Font.ColorIndex = 1
.HorizontalAlignment = xlCenter
Case Else
.Font.ColorIndex = 1
.HorizontalAlignment = xlRight
If .Row Mod 2 <> 0 Then
.Interior.ColorIndex = xlNone
Else
.Interior.ColorIndex = 15
End If
End Select
Else
MsgBox ("Der eingebene Wert ist ungültig.")
.ClearContents
End If
End With
Application.EnableEvents = True
End Sub

Gruß Heiko
PS: Rückmeldung wäre nett !
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige