Hallo,
Graag wil ik de na het opmaken van de facturen naar de opbrengsten.
Het zegt steeds: de facturen is verwerkt, maar bij de opbrengst zie ik niets..
Hierin de macro:
Sub Knopverwerkeninboekhouding()
'On Error GoTo ErrHandler:
Dim Datum, factnr, Relatie As String
Dim totaal As Double
Datum = Range("A16").Value
factnr = Range("C16").Value
Relatie = Range("A6").Value
For i = 19 To 24
Btw = Range("G16").Value2
bedrag = Range("G17")
'MsgBox bedrag
If Btw = "" And bedrag <> "" Then
MsgBox "Er is geen btw-percentage opgegeven in de factuur"
Exit Sub
End If
Next
If WorksheetFunction.CountA(Range("B19:D24")) = 0 Then
MsgBox "Er zijn geen factuurregels aanwezig"
Exit Sub
End If
If Relatie = "Kies relatie" Then
MsgBox "Er is geen relatie geselecteerd."
Exit Sub
End If
If Datum = "" Then
MsgBox "Er is geen datum ingevuld."
Exit Sub
End If
If factnr = "" Then
MsgBox "Er is geen factuurnumer ingevuld."
Exit Sub
End If
With Worksheets("Verkoopdagboek").Range("E3:E500")
Set C = .Find(Range("C16").Value, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False)
If Not C Is Nothing Then
MsgBox "Er is al een factuur met dit nummer aanwezig!"
Exit Sub
End If
End With
bedrag0 = 0
bedrag6 = 0
bedrag21 = 0
Dim omschrijving0, omschrijving6, omschrijving21 As String
For i = 19 To 24
Btw = Range("G16").Value2
bedrag = Range("G17")
Omschrijving = Range("B19:D24").Value
'MsgBox bedrag
If Btw <> "" And bedrag <> "" Then
If Btw = "0,21" Then
bedrag21 = bedrag21 + bedrag
omschrijving21 = omschrijving21 & "" & Range("B19:D24").Value
ElseIf Btw = "0,06" Then
bedrag9 = bedrag6 + bedrag
omschrijving6 = omschrijving6 & "" & Range("B19:D24").Value
Else
bedrag0 = bedrag0 + bedrag
omschrijving0 = omschrijving0 & "" & Range("B19:D24").Value
End If
End If
Next
' Turn off WorkSheet_Change event. This somehow clears the B4 field in this sheet
'Insert records
If bedrag21 <> 0 Then
With Sheets("Verkoopdagboek")
' .SetIgnoreChanges (True)
.Cells(LastRow, 1).Value = Datum 'Datum
.Cells(LastRow, 4).Value = "Factuur" 'fastuur
.Cells(LastRow, 5).Value = factnr 'Factuurnummer
.Cells(LastRow, 5).Value = omschrijving0 'Omschrijving
.Cells(LastRow, 6).Value = Range("A6").Value 'Relatie
.Cells(LastRow, 8).Value = Range("G30").Value 'Bedrag incl
.Cells(LastRow, 9).Value = "Niet Betaald" 'status
.BtwBerekening (LastRow)
End With
LastRow = LastRow + 1
End If
If bedrag6 <> 0 Then
With Sheets("Verkoopdagboek")
' .SetIgnoreChanges (True)
.Cells(LastRow, 2).Value = Datum 'Datum
.Cells(LastRow, 3).Value = "Factuur" 'fastuur
.Cells(LastRow, 4).Value = factnr 'Factuurnummer
.Cells(LastRow, 5).Value = omschrijving0 'Omschrijving
.Cells(LastRow, 6).Value = Range("A6").Value 'Relatie
.Cells(LastRow, 7).Value = bedrag6 'Bedrag ex
.Cells(LastRow, 8).Value = "6%" 'Btw tarief
.Cells(LastRow, 10).Value = "Niet Betaald" 'status
.BtwBerekening (LastRow)
End With
LastRow = LastRow + 1
End If
If bedrag0 <> 0 Then
With Sheets("Verkoopdagboek")
' .SetIgnoreChanges (True)
.Cells(LastRow, 2).Value = Datum 'Datum
.Cells(LastRow, 3).Value = "Factuur" 'factuur
.Cells(LastRow, 4).Value = factnr 'Factuurnummer
.Cells(LastRow, 5).Value = omschrijving0 'Omschrijving
.Cells(LastRow, 6).Value = Range("A6").Value 'Relatie
.Cells(LastRow, 7).Value = bedrag0 'Bedrag ex
.Cells(LastRow, 8).Value = "Geen btw" 'Btw tarief
.Cells(LastRow, 10).Value = "Niet Betaald" 'status
.BtwBerekening (LastRow)
End With
End If
MsgBox "Factuur is verwerkt"
Exit Sub
ErrHandler:
MsgBox "Er is iets mis gegaan"
Exit Sub
End Sub