Run time error 400 i VBA kode - HJÆLP :-) :-)
Hej,Jeg har en kode der driller mig lidt :-) Når man står i Excel filen og den aktive celle du står indeholder beskrivelse "Automatisk kontrol" eller "Manuel med automatisk kontrolelement" så har jeg lavet en UserForm, hvor der skal udfyldes nogle spørgsmål
Når man så klikker på knappen CommandButton1, så får jeg en fejlmeddelelse:
Run-time error '400':
Form already displayed; can't show modally
Når jeg trykker på Debug, så bliver linjen UserForm6.show markedt med gul
Hvad har jeg gjort forkert?
pft. ;-)
Kode der åbner Userform:
Private Sub Worksheet_Change(ByVal Target As Range)
If ActiveCell.Value = "Automatisk kontrol" Then
UserForm6.Show
Unload Me
ElseIf ActiveCell.Value = "Manuel med automatisk kontrolelement" Then
UserForm6.Show
Unload Me
Else
Exit Sub
End If
Kode til knappen: CommandButton1 i Userform:
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
ShtName = ActiveSheet.Name
Sheets(ShtName).Columns("AQ:DG").EntireColumn.Hidden = False
' xxxxxxxxxxxxxxxxxxx PENSION & SIKRING xxxxxxxxxxxxxxxxxxxxxxxx
Sheets(ShtName).Cells(2, 45) = CheckBox1.Value
Sheets(ShtName).Cells(3, 45) = CheckBox2.Value
Sheets(ShtName).Cells(4, 45) = CheckBox3.Value
Sheets(ShtName).Cells(5, 45) = CheckBox45.Value
'xxxxxxxxxxxxxxxxxxxxxx P & I xxxxxxxxxxxxxxxxxxxxx
Sheets(ShtName).Cells(2, 48) = CheckBox4.Value
Sheets(ShtName).Cells(3, 48) = CheckBox5.Value
Sheets(ShtName).Cells(4, 48) = CheckBox6.Value
Sheets(ShtName).Cells(5, 48) = CheckBox7.Value
Sheets(ShtName).Cells(6, 48) = CheckBox8.Value
Sheets(ShtName).Cells(7, 48) = CheckBox9.Value
Sheets(ShtName).Cells(8, 48) = CheckBox10.Value
Sheets(ShtName).Cells(9, 48) = CheckBox44.Value
'xxxxxxxxxxxxxxxxxxxxxx UDK xxxxxxxxxxxxxxxxxxxxx
Sheets(ShtName).Cells(2, 51) = CheckBox11.Value
Sheets(ShtName).Cells(3, 51) = CheckBox12.Value
Sheets(ShtName).Cells(4, 51) = CheckBox13.Value
Sheets(ShtName).Cells(5, 51) = CheckBox14.Value
Sheets(ShtName).Cells(6, 51) = CheckBox15.Value
Sheets(ShtName).Cells(7, 51) = CheckBox16.Value
Sheets(ShtName).Cells(8, 51) = CheckBox17.Value
Sheets(ShtName).Cells(9, 51) = CheckBox18.Value
Sheets(ShtName).Cells(10, 51) = CheckBox19.Value
Sheets(ShtName).Cells(11, 51) = CheckBox43.Value
' xxxxxxxxxxxxxxxxxxxxxx UDK xxxxxxxxxxxxxxxxxxxxx
Sheets(ShtName).Cells(2, 54) = CheckBox20.Value
Sheets(ShtName).Cells(3, 54) = CheckBox21.Value
Sheets(ShtName).Cells(4, 54) = CheckBox22.Value
Sheets(ShtName).Cells(5, 54) = CheckBox23.Value
Sheets(ShtName).Cells(6, 54) = CheckBox24.Value
Sheets(ShtName).Cells(7, 54) = CheckBox25.Value
Sheets(ShtName).Cells(8, 54) = CheckBox26.Value
Sheets(ShtName).Cells(9, 54) = CheckBox27.Value
Sheets(ShtName).Cells(10, 54) = CheckBox28.Value
Sheets(ShtName).Cells(11, 54) = CheckBox29.Value
Sheets(ShtName).Cells(12, 54) = CheckBox30.Value
Sheets(ShtName).Cells(13, 54) = CheckBox31.Value
Sheets(ShtName).Cells(14, 54) = CheckBox32.Value
Sheets(ShtName).Cells(15, 54) = CheckBox33.Value
Sheets(ShtName).Cells(16, 54) = CheckBox34.Value
Sheets(ShtName).Cells(17, 54) = CheckBox42.Value
'xxxxxxxxxxxxxxxxxxxxxx Øvrige xxxxxxxxxxxxxxxxxxxxx
Sheets(ShtName).Cells(2, 57) = CheckBox35.Value
Sheets(ShtName).Cells(3, 57) = CheckBox36.Value
Sheets(ShtName).Cells(4, 57) = CheckBox37.Value
Sheets(ShtName).Cells(5, 57) = CheckBox38.Value
Sheets(ShtName).Cells(6, 57) = CheckBox39.Value
Sheets(ShtName).Cells(7, 57) = CheckBox40.Value
Sheets(ShtName).Cells(8, 57) = CheckBox41.Value
Sheets(ShtName).Cells(9, 57) = CheckBox46.Value
Sheets(ShtName).Cells(10, 57) = CheckBox47.Value
Sheets(ShtName).Cells(2, 59) = TextBox1.Value
If Sheets(ShtName).Range("AR16").Value > 0 Then
Range("SystemerAndet").EntireRow.Hidden = False
Else
Range("SystemerAndet").EntireRow.Hidden = True
End If
Sheets(ShtName).Columns("AQ:DG").EntireColumn.Hidden = True
Range("SystemerAnvendt").EntireRow.Hidden = False
End Sub