AW: als Text gespeicherte Zahlen
30.09.2025 16:11:16
Alwin Weisangler
deine Prozedur nur passend geändert:
Sub BerechneProzentInZeile1()
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("1P") ' Blatt, auf dem berechnet wird
Dim vals(1 To 6) As Variant
Dim results(1 To 6) As Double
' Werte aus Zeile 1
vals(1) = ws.Cells(1, "Z").Value ' Z1
vals(2) = ws.Cells(1, "AB").Value ' AB1
vals(3) = ws.Cells(1, "AD").Value ' AD1
vals(4) = ws.Cells(1, "AF").Value ' AF1
vals(5) = ws.Cells(1, "AH").Value ' AH1
vals(6) = ws.Cells(1, "AJ").Value ' AJ1
' Berechnung 1/300 und Formatierung
Dim i As Long
For i = 1 To 6
If IsNumeric(vals(i)) And vals(i) > 0 Then
results(i) = vals(i) / 300
Else
results(i) = 0
End If
Next i
' Ergebnisse in AA, AC, AE, AG, AI, AK schreiben
ws.Cells(1, "AA").Value = results(1)
ws.Cells(1, "AA").NumberFormat = "0.0%"
ws.Cells(1, "AC").Value = results(2)
ws.Cells(1, "AC").NumberFormat = "0.0%"
ws.Cells(1, "AE").Value = results(3)
ws.Cells(1, "AE").NumberFormat = "0.0%"
ws.Cells(1, "AG").Value = results(4)
ws.Cells(1, "AG").NumberFormat = "0.0%"
ws.Cells(1, "AI").Value = results(5)
ws.Cells(1, "AG").NumberFormat = "0.00%"
ws.Cells(1, "AK").Value = results(6)
ws.Cells(1, "AG").NumberFormat = "0.0%"
MsgBox "Prozentwerte in Zeile 1 berechnet.", vbInformation
End Sub
Gruß Uwe