Live-Forum - Die aktuellen Beiträge
Datum
Titel
24.04.2024 19:29:30
24.04.2024 18:49:56
Anzeige
Archiv - Navigation
412to416
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
412to416
412to416
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Zahl in Worten
mike49
Hallo,
habe ein schönes Makro gefunden, das eine Zahl in Worten wiederholt. Wie müsste man es verändern, dass die Wortwiederholung immer mit Großbuchstaben beginnt?
Function inWorten$(wert$) Const Blöcke = 4 'max Anzahl von Dreierblöcken in einer Zahl (z.B. 4 = max bis 999 999 999 999) Dim Block$(Blöcke) Dim Text$(Blöcke) Dim Gruppe$(Blöcke) Dim GrEndSg$(Blöcke) Dim GrEndPl$(Blöcke) Dim Einer$(10) Dim Einer2$(10) Einer$(0) = "" Einer$(1) = "eins" Einer$(2) = "zwei" Einer$(3) = "drei" Einer$(4) = "vier" Einer$(5) = "fünf" Einer$(6) = "sechs" Einer$(7) = "sieben" Einer$(8) = "acht" Einer$(9) = "neun" Einer2$(0) = "" Einer2$(1) = "ein" Einer2$(2) = "zwei" Einer2$(3) = "drei" Einer2$(4) = "vier" Einer2$(5) = "fünf" Einer2$(6) = "sech" Einer2$(7) = "sieb" Einer2$(8) = "acht" Einer2$(9) = "neun" Gruppe$(1) = "" Gruppe$(2) = "tausend" Gruppe$(3) = "million" Gruppe$(4) = "milliarde" ' Gruppenendung Singular GrEndSg$(1) = "" GrEndSg$(2) = "" GrEndSg$(3) = "" GrEndSg$(4) = "" ' Gruppenendung Plural GrEndPl$(1) = "" GrEndPl$(2) = "" GrEndPl$(3) = "en" GrEndPl$(4) = "n" For i = 1 To Blöcke Block$(i) = "" Text$(i) = "" Next '* Alle Punkte entfernen pos = InStr(wert$, ".") While pos > 0 wert$ = Left$(wert$, pos - 1) + Right$(wert$, Len(wert$) - pos) pos = InStr(pos, wert$, ".") Wend '* Nachkommastellen NK$ schreiben pos = InStr(wert$, ",") If pos > 0 Then NK$ = Right$(wert$, Len(wert$) - pos) wert$ = Left$(wert$, pos - 1) Else NK$ = "" End If For i = 1 To Blöcke If Len(wert$) > 3 Then Block$(i) = Right$(wert$, 3) wert$ = Left$(wert$, Len(wert$) - 3) Else Block$(i) = wert$ wert$ = "" End If If Block$(i) <> "" Then If Len(Block$(i)) = 3 Then If Block$(i) = "000" Then Text$(i) = "" ElseIf Left$(Block$(i), 1) = "1" Then Text$(i) = "einhundert" ElseIf Left$(Block$(i), 1) = "0" Then Text$(i) = "" Else Text$(i) = Text$(i) + Einer$(Val(Left$(Block$(i), 1))) + "hundert" End If Block$(i) = Right$(Block$(i), 2) End If If Len(Block$(i)) = 2 Then If Left$(Block$(i), 1) = "0" Then Text$(i) = Text$(i) + Einer$(Val(Right$(Block$(i), 1))) ElseIf Left$(Block$(i), 1) = "1" Then If Left$(Block$(i), 2) = "11" Then Text$(i) = Text$(i) + "elf" ElseIf Left$(Block$(i), 2) = "12" Then Text$(i) = Text$(i) + "zwölf" Else Text$(i) = Text$(i) + Einer2$(Val(Right$(Block$(i), 1))) + "zehn" End If ElseIf Left$(Block$(i), 1) = "2" Then If Left$(Block$(i), 2) = "21" Then Text$(i) = Text$(i) + "ein" Else Text$(i) = Text$(i) + Einer$(Val(Right$(Block$(i), 1))) End If If Left$(Block$(i), 2) <> "20" Then Text$(i) = Text$(i) + "und" End If Text$(i) = Text$(i) + "zwanzig" ElseIf Left$(Block$(i), 1) = "3" Then If Left$(Block$(i), 2) = "31" Then Text$(i) = Text$(i) + "ein" Else Text$(i) = Text$(i) + Einer$(Val(Right$(Block$(i), 1))) End If If Left$(Block$(i), 2) <> "30" Then Text$(i) = Text$(i) + "und" End If Text$(i) = Text$(i) + "dreißig" Else If Right$(Block$(i), 1) = "1" Then Text$(i) = Text$(i) + "ein" Else Text$(i) = Text$(i) + Einer$(Val(Right$(Block$(i), 1))) End If If Right$(Block$(i), 1) <> "0" Then Text$(i) = Text$(i) + "und" End If Text$(i) = Text$(i) + Einer2$(Val(Left$(Block$(i), 1))) + "zig" End If End If If Len(Block$(i)) = 1 Then Text$(i) = Text$(i) + Einer$(Val(Right$(Block$(i), 1))) End If End If If Text$(i) <> "" Then End If Next For i = Blöcke To 1 Step -1 If Text$(i) <> "" Then If Text$(i) = "eins" Then If i > 2 Then Text$(i) = "eine" ElseIf i = 2 Then Text$(i) = "ein" End If Text$(i) = Text$(i) + Gruppe$(i) Text$(i) = Text$(i) + GrEndSg$(i) Else Text$(i) = Text$(i) + Gruppe$(i) Text$(i) = Text$(i) + GrEndPl$(i) End If End If TextG$ = TextG$ + Text$(i) Next If TextG$ = "" Then TextG$ = "null" End If If (NK$ <> "") And (NK$ <> "0") And (NK$ <> "00") Then If Len(NK$) = 1 Then NK$ = NK$ + "0" End If TextG$ = "( in Worten: " + TextG$ + " und " + NK$ + "/100 Euro )" End If ' TextG$ = Chr$(Asc(Left$(TextG$, 1)) - 32) + Right$(TextG$, Len(TextG$) - 1) inWorten$ = TextG$ End Function
Gruß mike49

12
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Benutzer
Anzeige
AW: Zahl in Worten
Florian
Hallo, Mike,
Gruß,
Florian
AW: Zahl in Worten
mike49
Hallo Florian,
wo genau soll das hin? Was fällt weg?
Gruß mike49
AW: Zahl in Worten
Florian
Hallo, Mike,
direkt vor "End Function".
Mit der Programmzeile wird einfach das erste Zeichen eines Textes (und die Zahl in Worten ist ja nun ein Text) groß geschrieben (UCase).
Gruß,
Florian
AW: Zahl in Worten
mike49
Hallo Florian,
funktioniert leider nicht.
Gruß mike49
Bequeme Lösung als Anhang
20.04.2004 22:08:06
Florian
Hallo, zusammen!
Hier eine komfortable Lösung:
https://www.herber.de/bbs/user/5458.xls
Zahl(en) eingeben und dann den Button Zwischenablage drücken.
Gruß,
Florian
P.S. Sorry für die späte Antwort. Aber (1) hat der Upload nicht funktioniert, weil ein Umlaut drin war ("ZahlwÖrter.xls"), und (2) war ich zwei Tage weg.
Anzeige
AW: Zahl in Worten
IngoG
Hallo Mike,
die Funktion von Florian sollte funzen ansonsten kannst Du auch einfach die auskommentierte Zeile wieder aktivieren
TextG$ = Chr$(Asc(Left$(TextG$, 1)) - 32) + Right$(TextG$, Len(TextG$) - 1)
Gruß Ingo
PS eine Rückmeldung wäre nett...
AW: Zahl in Worten
mike49
Hallo Ingo,
habe alle Varianten ausprobiert. Funktioniert einfach nicht. Mach ich was falsch?
Nach ( in Worten:
wird einfach nicht mit Großschreibung begonnen. Probier du's mal aus, ob es bei dir klappt.
Steht die Zahl z.B. in A1, gebe ich als Formel in die Zelle ein " =inWorten(A1) ".
Gruß mike49
AW: Zahl in Worten
IngoG
Hallo Mike,
Bei mir funzt es (nachdem ich einige Variablen nachdefiniert habe ;-))
Function inWorten$(wert$) Const Blöcke = 4 'max Anzahl von Dreierblöcken in einer Zahl (z.B. 4 = max bis 999 999 999 999) Dim Block$(Blöcke) Dim text$(Blöcke) Dim Gruppe$(Blöcke) Dim GrEndSg$(Blöcke) Dim GrEndPl$(Blöcke) Dim Einer$(10) Dim Einer2$(10) Dim i%, pos% Dim nk$, TextG$ Einer$(0) = "" Einer$(1) = "eins" Einer$(2) = "zwei" Einer$(3) = "drei" Einer$(4) = "vier" Einer$(5) = "fünf" Einer$(6) = "sechs" Einer$(7) = "sieben" Einer$(8) = "acht" Einer$(9) = "neun" Einer2$(0) = "" Einer2$(1) = "ein" Einer2$(2) = "zwei" Einer2$(3) = "drei" Einer2$(4) = "vier" Einer2$(5) = "fünf" Einer2$(6) = "sech" Einer2$(7) = "sieb" Einer2$(8) = "acht" Einer2$(9) = "neun" Gruppe$(1) = "" Gruppe$(2) = "tausend" Gruppe$(3) = "million" Gruppe$(4) = "milliarde" ' Gruppenendung Singular GrEndSg$(1) = "" GrEndSg$(2) = "" GrEndSg$(3) = "" GrEndSg$(4) = "" ' Gruppenendung Plural GrEndPl$(1) = "" GrEndPl$(2) = "" GrEndPl$(3) = "en" GrEndPl$(4) = "n" For i = 1 To Blöcke Block$(i) = "" text$(i) = "" Next '* Alle Punkte entfernen pos = InStr(wert$, ".") While pos > 0 wert$ = Left$(wert$, pos - 1) + Right$(wert$, Len(wert$) - pos) pos = InStr(pos, wert$, ".") Wend '* Nachkommastellen NK$ schreiben pos = InStr(wert$, ",") If pos > 0 Then nk$ = Right$(wert$, Len(wert$) - pos) wert$ = Left$(wert$, pos - 1) Else nk$ = "" End If For i = 1 To Blöcke If Len(wert$) > 3 Then Block$(i) = Right$(wert$, 3) wert$ = Left$(wert$, Len(wert$) - 3) Else Block$(i) = wert$ wert$ = "" End If If Block$(i) <> "" Then If Len(Block$(i)) = 3 Then If Block$(i) = "000" Then text$(i) = "" ElseIf Left$(Block$(i), 1) = "1" Then text$(i) = "einhundert" ElseIf Left$(Block$(i), 1) = "0" Then text$(i) = "" Else text$(i) = text$(i) + Einer$(Val(Left$(Block$(i), 1))) + "hundert" End If Block$(i) = Right$(Block$(i), 2) End If If Len(Block$(i)) = 2 Then If Left$(Block$(i), 1) = "0" Then text$(i) = text$(i) + Einer$(Val(Right$(Block$(i), 1))) ElseIf Left$(Block$(i), 1) = "1" Then If Left$(Block$(i), 2) = "11" Then text$(i) = text$(i) + "elf" ElseIf Left$(Block$(i), 2) = "12" Then text$(i) = text$(i) + "zwölf" Else text$(i) = text$(i) + Einer2$(Val(Right$(Block$(i), 1))) + "zehn" End If ElseIf Left$(Block$(i), 1) = "2" Then If Left$(Block$(i), 2) = "21" Then text$(i) = text$(i) + "ein" Else text$(i) = text$(i) + Einer$(Val(Right$(Block$(i), 1))) End If If Left$(Block$(i), 2) <> "20" Then text$(i) = text$(i) + "und" End If text$(i) = text$(i) + "zwanzig" ElseIf Left$(Block$(i), 1) = "3" Then If Left$(Block$(i), 2) = "31" Then text$(i) = text$(i) + "ein" Else text$(i) = text$(i) + Einer$(Val(Right$(Block$(i), 1))) End If If Left$(Block$(i), 2) <> "30" Then text$(i) = text$(i) + "und" End If text$(i) = text$(i) + "dreißig" Else If Right$(Block$(i), 1) = "1" Then text$(i) = text$(i) + "ein" Else text$(i) = text$(i) + Einer$(Val(Right$(Block$(i), 1))) End If If Right$(Block$(i), 1) <> "0" Then text$(i) = text$(i) + "und" End If text$(i) = text$(i) + Einer2$(Val(Left$(Block$(i), 1))) + "zig" End If End If If Len(Block$(i)) = 1 Then text$(i) = text$(i) + Einer$(Val(Right$(Block$(i), 1))) End If End If If text$(i) <> "" Then End If Next For i = Blöcke To 1 Step -1 If text$(i) <> "" Then If text$(i) = "eins" Then If i > 2 Then text$(i) = "eine" ElseIf i = 2 Then text$(i) = "ein" End If text$(i) = text$(i) + Gruppe$(i) text$(i) = text$(i) + GrEndSg$(i) Else text$(i) = text$(i) + Gruppe$(i) text$(i) = text$(i) + GrEndPl$(i) End If End If TextG$ = TextG$ + text$(i) Next If TextG$ = "" Then TextG$ = "null" End If If (nk$ <> "") And (nk$ <> "0") And (nk$ <> "00") Then If Len(nk$) = 1 Then nk$ = nk$ + "0" End If TextG$ = "( in Worten: " + TextG$ + " und " + nk$ + "/100 Euro )" End If TextG$ = Chr$(Asc(Left$(TextG$, 1)) - 32) + Right$(TextG$, Len(TextG$) - 1) inWorten$ = TextG$ End Function
Gruß Ingo
PS eine Rückmeldung wäre nett...
Anzeige
AW: Zahl in Worten
mike49
Hallo Ingo,
danke für deine Mühe. Habe den Code übernommen. Sieht bei mir jetzt so aus:
 
 ABCDEFG
11243,54 in Worten: eintausendzweihundertdreiundvierzig und 54/100 Euro )     
Formeln der Tabelle
B1 : =inWorten(A1)
 
Diagramm - Grafik - Excel Tabellen einfach im Web darstellen    Excel Jeanie HTML  3.0    Download  
Gruß
mike49
Anzeige
AW: Zahl in Worten
IngoG
Hallo Mike,
hatte nur ganzzahliege werte getestet ;-)
wenn du die Zeile
TextG$ = Chr$(Asc(Left$(TextG$, 1)) - 32) + Right$(TextG$, Len(TextG$) - 1)
Durch folgende ersetzt funzt es auch für nachkommawerte
If Right$(TextG$, 1) = ")" Then
TextG$ = Left$(TextG$, 13) + Chr$(Asc(Mid$(TextG$, 14, 1)) - 32) + Right$(TextG$, Len(TextG$) - 14)
Else
TextG$ = Chr$(Asc(Left$(TextG$, 1)) - 32) + Right$(TextG$, Len(TextG$) - 1)
End If
Gruß ingo
PS eine Rückmeldung wäre nett...
Jetzt klappt's super.
mike49
Nochmals vielen Dank für deine Hilfe.
Gruß
mike49
Danke für die Rückmeldung oT
IngoG
.

305 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige