Verteilung Bestand auf Filialen
11.02.2023 01:22:21
Sverk
ich komm leider nicht weiter bei meinem Problem..
ich habe euch mal meine beiden tabellen angehangen.
https://www.herber.de/bbs/user/157778.xlsm
Tabelle1 ist eine Auswertung die die Umsatzanteiligkeit der Filialen in einer bestimmten Marke darstellt. in Tabelle 2 sind Artikel mit einer Menge, die anhand der Anteiligkeit auf die Filialen durch folgenden VBA-Code:
Sub VerteileMengen_alleFilialen()
Dim ws1 As Worksheet, ws2 As Worksheet
Dim lastRow1 As Long, lastRow2 As Long
Dim i As Long, j As Long
Dim marke As Long, artikel As Long, filiale As Long, menge As Long
Dim anteil As Double, ganzeZahl As Long, verbleib As Long
Set ws1 = ThisWorkbook.Sheets("Tabelle1")
Set ws2 = ThisWorkbook.Sheets("Tabelle2")
lastRow1 = ws1.Cells(ws1.Rows.Count, "A").End(xlUp).Row
lastRow2 = ws2.Cells(ws2.Rows.Count, "A").End(xlUp).Row
For i = 2 To lastRow2
marke = ws2.Cells(i, 1).Value
artikel = ws2.Cells(i, 2).Value
menge = ws2.Cells(i, 3).Value
verbleib = menge
For j = 2 To lastRow1
If ws1.Cells(j, 1).Value = marke Then
filiale = ws1.Cells(j, 3).Value
anteil = ws1.Cells(j, 5).Value
ganzeZahl = menge * anteil
ganzeZahl = Int(ganzeZahl + 0.5)
ws2.Cells(i, 3 + filiale).Value = ganzeZahl
verbleib = verbleib - ganzeZahl
End If
Next j
Next i
End Sub
dieser funktioniert auch schon ganz gut.
Nun zu meinem Problem:
Ich würde gern eine inputbox erstellen und eine Anzahl an Filialen bestimmen, auf die die Menge verteilt werden soll. Alles anhand der Anteiligkeiten.
Die Inputbox krieg ich hin aber ich komm leider bei dem Code nicht weiter der das umsetzt, wie ich das will.