Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
556to560
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
556to560
556to560
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Umwandlung

Umwandlung
27.01.2005 19:51:34
Grainne
Hallo,
ich habe folgendes Problem:
ich habe eine Zahl in einer Zelle stehen und möchte diese nun in einer nebenstehenden Zelle in Ziffern stehen haben, ohne dass ich es ausschreiben muss.
Also folgendes:
in Zelle A3 steht der wert 15,75
ich möchte dass ich in irgendeiner Zelle einfügen kann: irgendeine formel und A3 und es schreibt mir dort fünfzehnkommafünfundsiebzig.
Ist so ähnlich wie die Funktion Bahttext, nur brauch ich den Text in Deutsch bzw. italienisch und nicht in Thai.
Wäre dankbar über eine Lösung,
ansonsten werde ich Sonntag durcharbeiten müssen.
Claudia

7
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Umwandlung
27.01.2005 20:00:08
Josef
Hallo Claudia!
Kopiere diesen Code in ein allgemeines Modul.


      
Function inWorten2(wert As StringAs String
    
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$
    
Dim neg As String
    
If wert < 0 Then
         neg = 
"minus "
         wert = Right(wert, Len(wert) - 1)
    
End If
     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$ = 
" "
    
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$ + " Komma " + inWorten2(nk$) + ")"
    
End If
    
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
     inWorten2 = neg & TextG$
End Function 
P.S.: Rückmeldung nicht vergessen!
Anzeige
Eintrag immer an das Ende stellen
27.01.2005 21:08:28
Wilfried
Hallo Sepp,
ich muss über diese Weg danke sagen, denn ich stehe schon im Archiv. Hatte leider keine Zeit um sofort zu antworten.
mit freundlichen Grüssen
Wilfried
P.S. Sollte es eine Möglichkeit geben aus dem Archiv zu antworten teile sie mir bitte mit.
AW: Eintrag immer an das Ende stellen
28.01.2005 12:50:10
claudia
vielen vielen dank für die Antwort,
leider reichen meine excel-kenntnisse dafür nicht aus.
ich habe zwar geschaft ein modul zu öffen und zu kopieren, aber dann war auch schon fertig - bin eben nur sekretärin (blond) :)
Außerdem brauch ich die Zahlen auf Italienisch und Kommastellen kommen wahrscheinlich auch vor....
Aber trotzdem noch vielen Dank für die Bemühungen, ist wirklich interessant was so alles geht.
Claudia
Anzeige
AW: Eintrag immer an das Ende stellen
28.01.2005 14:37:58
wilfried
Hallo Sepp,
vieleicht kannst Du dich noch erinnern.
Wie kann man erreichen das man mit den Kilometern die in Spalte "H" stehen nun rechnen kann. z.Z. ist es nur Text.
Danke
Wilfried
@Wilfried!
28.01.2005 16:51:03
Josef
Hallo Wilfried!
Poste bitte in Zukunft deine Fragen nicht in den Thread eines anderen!
Zu deiner Frage:
Wie stehen den die Km in der Combobox?
Nur die Zahl, mit "Km" ?
Eine Möglichkeit währe " = CDbl(Replace(Combobox1, " Km", "")) ",
wenn du zB. "78,25 Km" in der Combobox stehen hast!
Gruß Sepp
P.S.: Rückmeldung nicht vergessen!
Eintrag immer an das Ende stellen
28.01.2005 17:10:59
Wilfried
Hallo Sepp,
wie schon gesagt ich stand bereits im Archiv und wuste nicht wie ich an den alten Thread rankommen sollte. In der ComboBox stehen nur die Zahlen ohne Km. es brauchen nur die Zahl z.b. "14" stehen, ohne Km angabe.
Gruß wilfried
Anzeige
= CDbl(ComboBox1) o.T.
28.01.2005 17:16:29
Josef
Gruß Sepp

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige