FIFO mit VBA (Endlosschleife?)
21.08.2008 21:06:36
Bernhard
da ich in VBA noch ziemlich unbeleckt bin, habe ich zur Lösung einer FIFO Aufgabenstellung u.a. VBA Lösung ergoogelt, die eigentlich funktioniert, lediglich der 2. Teil Starting_Inventory läuft scheinbar in eine Endlosschleife. Was ist falsch? Habe auch ein Beispieldatei hochgeladen.
https://www.herber.de/bbs/user/54795.xls
Sub Update_Inventory()
Starting_Inventory
Dim endrow As Long 'last row in range
Dim Title As String 'book title
Dim Mycell As Range 'Cell with sold book title
'Dim MyCell2 As Range
Dim qtySell As Long 'Sell volume in current row
Dim i As Long 'row counter
Dim buysell As Range
Dim MyRow As Long
Dim RemInv As String
Dim invred As Long
Dim Lastrow As Long 'row above sell transaction
endrow = Range("A" & Rows.Count).End(xlUp).Row
Set buysell = Range("B1:B" & endrow).Find("Sell", LookIn:=xlValues)
If buysell Is Nothing Then
Exit Sub
End If
For i = Range(buysell.Address).Row To endrow Step 1
Title = Range(buysell.Address).Offset(0, -1).Value
qtySell = buysell.Offset(0, 2).Value
Lastrow = buysell.Row - 1
For Each Mycell In Range("A1:A" & Lastrow)
Do While MyRow Title Then
GoTo nextmycell:
ElseIf Mycell.Offset(0, 1).Value = "buy" Then
RemInv = Range(Mycell.Address).Offset(0, 6).Address
If Range(RemInv).Value = 0 Then
GoTo nextmycell:
ElseIf qtySell
Sub Starting_Inventory()
Dim endrow As Long
Dim Mycell As Range
endrow = Range("A" & Rows.Count).End(xlUp).Row
For Each Mycell In Range("A1:A" & endrow)
If Mycell.Offset(0, 1).Value = "buy" Then
Mycell.Offset(0, 6).Value = Mycell.Offset(0, 3).Value
End If
Next Mycell
End Sub
Für eure Hilfe bin ich sehr dankbar.
Viele Grüsse
Bernhard