Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| programmierung:vba [2025/05/11 14:15] – swe | programmierung:vba [2025/12/20 14:53] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ## Funktionsdeklaration | + | ## Erstellen eines VBA-Skripts |
| + | ### Funktionsdeklaration | ||
| Anfang | Anfang | ||
| Line 12: | Line 13: | ||
| - Im Beispiel: `Bereich` als `Range` deklariert - Funktion erwartet einen Zellbereich als Eingabe | - Im Beispiel: `Bereich` als `Range` deklariert - Funktion erwartet einen Zellbereich als Eingabe | ||
| - | ## Variablendeklaration mit Dim und Initialisierung | + | ### Variablendeklaration mit Dim und Initialisierung |
| **Variablendeklaration** | **Variablendeklaration** | ||
| Line 34: | Line 35: | ||
| - `Summe` und `Anzahl` werden auf 0 initialisiert. | - `Summe` und `Anzahl` werden auf 0 initialisiert. | ||
| - | ## Schleife durch den Bereich durch For Each und Next | + | ### Schleife durch den Bereich durch For Each und Next |
| ```vba | ```vba | ||
| For Each Zelle In Bereich | For Each Zelle In Bereich | ||
| Line 48: | Line 49: | ||
| - | ## Berechnung des Durchschnitts | + | ### Berechnung des Durchschnitts |
| ```vba | ```vba | ||
| If Anzahl > 0 Then | If Anzahl > 0 Then | ||
| Line 60: | Line 61: | ||
| - | ## Code | + | ### Code |
| ```vba | ```vba | ||
| Function DurchschnittBerechnen(Bereich As Range) As Double | Function DurchschnittBerechnen(Bereich As Range) As Double | ||
| Line 84: | Line 85: | ||
| End Function | End Function | ||
| ``` | ``` | ||
| + | |||
| + | ## Datentypen in VBA | ||
| + | |||
| + | |||
| + | | Datentyp | ||
| + | |---------------|-------------------------------------------------------------------------------------------------|----------------|--------------------------------------------------------------------------------------------------| | ||
| + | | `Integer` | ||
| + | | `Long` | ||
| + | | `Single` | ||
| + | | `Double` | ||
| + | | `Currency` | ||
| + | | `String` | ||
| + | | `Boolean` | ||
| + | | `Date` | ||
| + | | `Object` | ||
| + | | `Variant` | ||
| + | | `Byte` | ||
| + | |||
| + | ## Type-Checking-Functions (Typüberprüfungsfunktionen) in VBA | ||
| + | |||
| + | Hier ist eine Tabelle mit den Funktionen in VBA, die verwendet werden, um verschiedene Bedingungen zu überprüfen: | ||
| + | |||
| + | | Funktion | ||
| + | |---------------|-------------------------------------------------------------------------------------------------| | ||
| + | | `IsNumeric` | ||
| + | | `IsDate` | ||
| + | | `IsEmpty` | ||
| + | | `IsNull` | ||
| + | | `IsError` | ||
| + | | `IsArray` | ||
| + | | `IsObject` | ||
| + | | `TypeName` | ||
| + | | `VarType` | ||
| + | |||