Hi everybody,

I made a form which opens "on activate worksheet". Everything worked fine. I then needed to use the same form (with a few alterations) on another sheet in the same book. So I made a new form using the first one as a template, and everything worked fine. I opened the second sheet and up popped the form. I closed it, and opened the first one (the one that worked from the start), and got a system error "&H80070057 (-2147024809)", and when clicking OK got an error 361. The debug shows the show-command in the "worksheet activate" as the cause...

Being a total newbie to VB the following code might seem, well, strange to some...
Private Sub cmdCancel_Click()
    Unload Me
End Sub

Private Sub cmdClearForm_Click()
    Call UserForm_Clear
End Sub

Private Sub cmdOK_Click()
    Dim RIJ As Long
    Dim BON As Byte
    Dim SORT As Byte
    Dim HC As Single
    Dim RBT As Single
    Dim RBH As Single
    Dim GB As Single
    Dim BD As Single
    Dim TAanvoer As Single
    Dim BAanvoer As Single
    Dim NAanvoer As Single
    Dim BVodden As Single
    Dim TVodden As Single
    Dim NVodden As Single
    Dim FIJN As Single
    Dim D2 As Long
    Dim IsoWeekNumber As Long
    Dim G5 As Single
    Dim H5 As Single
    Dim Nacht As Byte
    Dim I5 As Byte
    Dim J5 As Byte
    Dim K5 As Byte
    Dim M5 As Single
    Dim P5 As Single
    
' TVodden = tarra vodden = gewicht draadkooi
    TVodden = 50.1
    
    RIJ = Range("Y1").Value + 1
    
    ActiveWorkbook.Sheets("Textiel").Activate
    Range("A" & RIJ).Select
    ActiveCell.Value = cboKanaal.Value
    ActiveCell.Offset(0, 1) = cboRegio.Value
    
    If optEuropallet = True Then
        HC = 22.7
    ElseIf optWegwerppallet = True Then
        HC = 14
    ElseIf optDraadkooi = True Then
        HC = 50.1
    ElseIf optElectrokar = True Then
        HC = 73
    ElseIf optRolkooi1 = True Then
        HC = 32.8
    ElseIf optRolkooi2 = True Then
        HC = 41.6
    Else
        HC = 50
    End If
    RBT = txtRBtextiel.Value * 2.5
    RBH = txtRBhuisraad.Value * 3
    GB = txtRBhuisraad.Value * 3
    BD = txtBananedozen.Value * 1.3
    BAanvoer = txtTotaalGewicht.Value
    TAanvoer = HC + RBT + RBH + GB + BD
    NAanvoer = BAanvoer - TAanvoer
    
    ActiveCell.Offset(0, 2) = NAanvoer
    ActiveCell.Offset(0, 3) = CDate(dteVerwerking.Value)
    
    D2 = DateSerial(Year(CDate(dteVerwerking.Value) - Weekday(CDate(dteVerwerking.Value) - 1) + 4), 1, 3)
    IsoWeekNumber = Int((CDate(dteVerwerking.Value) - D2 + Weekday(D2) + 5) / 7)
    
    If optEen = True Then
        BON = 1
    ElseIf optTwee = True Then
        BON = 2
    ElseIf optDrie = True Then
        BON = 3
    End If
    SORT = txtSorteerders.Value
    BVodden = txtGewichtVodden.Value
    NVodden = BVodden - TVodden
    
    ActiveCell.Offset(0, 4) = SORT
    ActiveCell.Offset(0, 5) = txtAanvang.Value
    ActiveCell.Offset(0, 6) = txtEinde.Value
    ActiveCell.Offset(0, 7) = NVodden / BON
    ActiveCell.Offset(0, 8) = IsoWeekNumber
    
    G5 = TimeValue(txtAanvang)
    H5 = TimeValue(txtEinde)
    
    If H5 < G5 And H5 > 0.340277777777778 And G5 < 0.715277777777778 Then Nacht = 1 Else Nacht = 0
        
    If Nacht = 0 Then
        If G5 < 0.423611111111111 And H5 > 0.434027777777778 Then I5 = 1 Else I5 = 0
    Else
        If G5 < 0.423611111111111 Then I5 = 1 Else I5 = 0
    End If
            
    If Nacht = 0 Then
        If G5 < 0.517361111111111 And H5 > 0.538194444444444 Then J5 = 1 Else J5 = 0
    Else
        If G5 < 0.517361111111111 Then J5 = 1 Else J5 = 0
    End If
    
    If Nacht = 0 Then
        If G5 < 0.631944444444444 And H5 > 0.642361111111111 Then K5 = 1 Else K5 = 0
    Else
        If G5 < 0.631944444444444 Then K5 = 1 Else K5 = 0
    End If
    
    M5 = I5 * 1.04166666666667E-02 + J5 * 1.04166666666667E-02 * 2 + K5 * 1.04166666666667E-02
    
    If Nacht = 1 Then P5 = Hour((H5 - 0.340277777777778) + (0.715277777777778 - G5) - M5) * 60 + Minute((H5 - 0.340277777777778) + (0.715277777777778 - G5) - M5) Else P5 = Hour(H5 - G5) * 60 + Minute(H5 - G5) - Hour(M5) * 60 - Minute(M5)
    
    ActiveCell.Offset(0, 9) = P5
    FIJN = NAanvoer - NVodden
    ActiveCell.Offset(0, 10) = FIJN
    ActiveCell.Offset(0, 11) = RIJ
    
    Range("A1").Select
    Unload Me
    frmTextiel.Show
End Sub

Private Sub UserForm_Initialize()
    With cboKanaal
        .AddItem "Op afroep"
        .AddItem "Gebracht"
        .AddItem "Containerpark"
    End With
    cboKanaal.Value = ""
    With cboRegio
        .AddItem "Beernem"
        .AddItem "Blankenberge"
        .AddItem "Brugge"
        .AddItem "Damme"
        .AddItem "De Haan"
        .AddItem "Jabbeke"
        .AddItem "Knokke"
        .AddItem "Oostkamp"
        .AddItem "Ruddervoorde"
        .AddItem "Zedelgem"
        .AddItem "Zuienkerke"
    End With
    cboRegio.Value = ""
    optDraadkooi = True
    txtRBtextiel.Value = 0
    txtRBhuisraad.Value = 0
    txtGrijze.Value = 0
    txtBananedozen.Value = 0
    txtTotaalGewicht.Value = 0
    dteVerwerking.Value = ""
    txtSorteerders.Value = 0
    txtAanvang.Value = ""
    txtEinde.Value = ""
    txtGewichtVodden.Value = 0
    optEen = True
End Sub

Private Sub UserForm_Clear()
    cboKanaal.Value = ""
    cboRegio.Value = ""
    optDraadkooi = True
    txtRBtextiel.Value = 0
    txtRBhuisraad.Value = 0
    txtGrijze.Value = 0
    txtBananedozen.Value = 0
    txtTotaalGewicht.Value = 0
    dteVerwerking.Value = ""
    txtSorteerders.Value = 0
    txtAanvang.Value = ""
    txtEinde.Value = ""
    txtGewichtVodden.Value = 0
    optEen = True
End Sub
The code of the second form is essentially the same.

Anybody any ideas?