ISDATUM() Eigen Functie
In Excel kan je met behulp van VBA (Alt-F11 , Visual Basic for Applications) je eigen functie maken.
In onderstaand voorbeeld wordt de functie IsEenDatum() gemaakt.
bron: http://microsoft.public.nl.office.excel.narkive.com/TLflGeja/type-veld
https://reinder.eu/blog/excel-vba/eigen-functie-maken-in-excel
Open VBA met de toetscombinatie Alt-F11
- Klik op de bestandsnaam en kies voor: Invoegen - Module

- Type de code:
- Function isEenDatum(rng As Range)
Application.Volatile
If rng.Cells.Count > 1 Then
isEenDatum = CVErr(xlErrRef)
ElseIf IsDate(rng) Then
isEenDatum = True
Else
isEenDatum = False
End If
End Function
- Klik links boven op het Excel pictogram om terug te keren naar het Excel werkblad.
- Kies voor het tabje 'Formules'
- Kies voor 'Datum en Tijd'
- Kies voor 'Functie invoegen'


- Kies bij 'Of selecteer een categorie' voor 'Door gebruiker gedefinieerd'

- Selecteer de functie die is gemaakt: IsEenDatum

- In beeld komt een venster waarin je cel kan opgeven waarin al- of niet een datum staat.

- Uitkomst is WAAR of ONWAAR.
=IsEenDatum(c2)
- Maar natuurlijk is het ook handig samen met de ALS functie.
=ALS(isEenDatum(C2);"Waar";"klopt niet")
BEWAREN VOOR GEBRUIK IN NIEUWE MAPPEN
- Sla het bestand waarin de Module met de code is gemaakt op als 'Excel-invoegtoepassing (*.xlam)

- Let goed op dat het wordt opgeslagen op de plaats waar Excel dit soort bestanden verwacht !

- Sluit vervolgens alle excel bestanden af.
- Start Excel opnieuw op
- Excel 2007: Kies: Opties - Invoegtoepassingen
- Kies de nieuwe functie
- Klik op Start

- Zet een vinkje bij 'Iseendatum'
- Klaar voor gebruik !