[Excel-VBA] Typ einer Zelle ermitteln
Gepostet am: Nov 21, 2012 9:9:7 PM
CellType
Public Function CellType(myCell As Range) As String Dim c As Range Set c = Range(myCell.Address) Application.Volatile Select Case True Case IsEmpty(c): CellType = "Blank" Case Application.IsText(c): CellType = "Text" Case Application.IsLogical(c): CellType = "Logical" Case Application.IsErr(c): CellType = "Error" Case IsDate(c): CellType = "Date" Case InStr(1, c.Text, ":") <> 0: CellType = "Time" Case IsNumeric(c): CellType = "Value" End Select If CellType = "Value" Then If c.Value = 0 Then CellType = "Null" ElseIf InStr(c.Value, Dezimaltrennzeichen) Then CellType = "Double" Else CellType = "Integer" End If End IfEnd Function
bzw.
Textfeld
Public Function CellType2(myCell As Range) As String CellType2 = TypeName(myCell.Value)End Function