In bijlage mijn code. Hij vraagt twee keer of het een "Part" of "Complete" sale is. Terwijl dit maar 1x zou mogen. Maar kan de fout niet vinden.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim strSale As String
Dim dblCarats As Double
Dim dblA1 As Double
Dim dblTot1 As Double
Dim dblF1 As Double
Dim dblTot2 As Double
Static oldRange As Range
If Not oldRange Is Nothing Then
If oldRange.Address = "$AA$2" Then
strSale = InputBox("Part or Complete?")
If strSale = "Part" Then
Worksheets("Sheet1").Rows(2).Select
'Insert row below active cell
ActiveCell.Offset(1).EntireRow.Insert
Worksheets("Sheet1").Rows(2).Select
'Insert row below active cell
ActiveCell.Offset(1).EntireRow.Insert
Range("A2:Y2").Font.Color = vbGreen
Range("A3:Y3").Font.Color = vbRed
Range("A4:Y4").Font.Color = vbBlack
Range("B3").Value = Range("B2").Value
Range("B4").Value = Range("B2").Value
Range("C3").Value = Range("C2").Value & "A"
Range("C4").Value = Range("C2").Value & "B"
Range("D3").Value = Range("B3").Value & "-" & Range("C3").Value
Range("D4").Value = Range("B4").Value & "-" & Range("C4").Value
strCarats = InputBox("How many carats has been sold?")
strF1 = InputBox("What was the final price per Carat?")
Range("L3").Value = strCarats
Range("O3").Value = strF1
Range("P3").Value = strF1 * strCarats
Range("L4").Value = Range("L2").Value - Range("L3").Value
Range("M4").Value = Range("M2").Value
Range("N4").Value = Range("M2").Value * Range("L4").Value
ElseIf strSale <> "Part" And strSale <> "Complete" Then
strSale = InputBox("Part or Complete?")
ElseIf strSale = "Complete" Then
Range("A2:Y2").Font.Color = vbRed
Range("M2
2").Locked = True
End If
End If
End If
Set oldRange = Target
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim strSale As String
Dim dblCarats As Double
Dim dblA1 As Double
Dim dblTot1 As Double
Dim dblF1 As Double
Dim dblTot2 As Double
Static oldRange As Range
If Not oldRange Is Nothing Then
If oldRange.Address = "$AA$2" Then
strSale = InputBox("Part or Complete?")
If strSale = "Part" Then
Worksheets("Sheet1").Rows(2).Select
'Insert row below active cell
ActiveCell.Offset(1).EntireRow.Insert
Worksheets("Sheet1").Rows(2).Select
'Insert row below active cell
ActiveCell.Offset(1).EntireRow.Insert
Range("A2:Y2").Font.Color = vbGreen
Range("A3:Y3").Font.Color = vbRed
Range("A4:Y4").Font.Color = vbBlack
Range("B3").Value = Range("B2").Value
Range("B4").Value = Range("B2").Value
Range("C3").Value = Range("C2").Value & "A"
Range("C4").Value = Range("C2").Value & "B"
Range("D3").Value = Range("B3").Value & "-" & Range("C3").Value
Range("D4").Value = Range("B4").Value & "-" & Range("C4").Value
strCarats = InputBox("How many carats has been sold?")
strF1 = InputBox("What was the final price per Carat?")
Range("L3").Value = strCarats
Range("O3").Value = strF1
Range("P3").Value = strF1 * strCarats
Range("L4").Value = Range("L2").Value - Range("L3").Value
Range("M4").Value = Range("M2").Value
Range("N4").Value = Range("M2").Value * Range("L4").Value
ElseIf strSale <> "Part" And strSale <> "Complete" Then
strSale = InputBox("Part or Complete?")
ElseIf strSale = "Complete" Then
Range("A2:Y2").Font.Color = vbRed
Range("M2

End If
End If
End If
Set oldRange = Target
End Sub