Vb aar2 fejl
jeg er ved at lave en kode som ud for en combobox laver to tingovertagelse og bytte men jeg kan ikke få bytte til at virke den laver fejl i Arr2 delen er der en som kan se hvor fejlen er!?
Private Sub BytOkCommand_Click()
Dim Arr(255, 3)
Dim Arr2(255, 3)
Dim o, p, k, l, i, h As Integer
Dim rng As Range
Dim FindDato As String
FindDato = BVagtDatoBox.Text
FindDato2 = BVagtDato2Box.Text
Sheets("1").Select
Set rng = Range("A:A")
For Each v In rng
If v.Text = FindDato Then
p = v.Row
Exit For
End If
Next v
For k = 6 To 255
Arr(k - 1, 0) = Cells(p, k).Value
Arr(k - 1, 1) = Cells(p + 1, k).Value
Arr(k - 1, 2) = Cells(p + 1, k + 1).Value
Arr(k - 1, 3) = Cells(1, k).Value
Next k
Set rng = Range("A:A")
For Each i In rng
If v.Text = FindDato2 Then
h = i.Row
Exit For
End If
Next i
For l = 6 To 255
Arr2(l - 1, 0) = Cells(h, l).Value
Arr2(l - 1, 1) = Cells(h + 1, l).Value
Arr2(l - 1, 2) = Cells(h + 1, l + 1).Value
Arr2(l - 1, 3) = Cells(1, l).Value
Next l
Sheets("1").Activate
For k = 6 To 255
For l = 6 To 255
If NavnBytteCombo.Value = Arr(k - 1, 3) Then
If OBVagtCombo.Value = "Bytte" Then
For x = 1 To 1
If Cells(p, k).Offset(2 * (x - 1)).Value <> "" Then
Cells(h, k).Offset(2 * (x - 1)) = BVognCombo.Value
Cells(p, k).Offset(2 * (x - 1)) = ""
Cells(p, k + 1).Offset(2 * (x - 1)) = ""
End If
If Cells(h, k).Offset(2 * (x - 1)).Value <> "" Then
Cells(h, k + 1) = "Byttede Vagt med " & NavnBOCombo & ". d. " & BVagtDato2Box
End If
Next
ElseIf OBVagtCombo.Value = "Overtagelse" Then
For x = 1 To 1
If Cells(p, k).Offset(2 * (x - 1)).Value = "" Then
Cells(p, k).Offset(2 * (x - 1)) = BVognCombo.Value
End If
If Cells(p, k).Offset(2 * (x - 1)).Value <> "" Then
Cells(p, k + 1) = "Over taget Vagt For " & NavnBOCombo & BVagtDatoBox
End If
Next
End If
End If
If NavnBOCombo.Value = Arr2(l - 1, 3) Then
If OBVagtCombo.Value = "Bytte" Then
For x = 1 To 1
If Cells(h, l).Offset(2 * (x - 1)).Value <> "" Then
Cells(p, l).Offset(2 * (x - 1)) = BVogn2Combo.Value
Cells(h, l).Offset(2 * (x - 1)) = ""
Cells(h, l + 1).Offset(2 * (x - 1)) = ""
End If
If Cells(p, l).Offset(2 * (x - 1)).Value <> "" Then
Cells(p, l + 1) = "Byttede Vagt med " & NavnBytteCombo & ". d. " & BVagtDatoBox
End If
Next
ElseIf OBVagtCombo.Value = "Overtagelse" Then
For x = 1 To 1
If Cells(p, l).Offset(2 * (x - 1)).Value <> "" Then
Cells(p, l).Offset(2 * (x - 1)) = ""
End If
If Cells(p, l).Offset(2 * (x - 1)).Value = "" Then
Cells(p, l + 1) = "Overgivet Vagten Til " & NavnBytteCombo & BVagtDato2Box
End If
Next
End If
End If
Next l
Next k
Application.ScreenUpdating = True
End Sub
