userform benutzung

Dieses Thema userform benutzung im Forum "Microsoft Office Suite" wurde erstellt von simdipl, 31. Aug. 2005.

Thema: userform benutzung Hallo zusammen Ich versucht mich mal in der Benutzung von userfroms aber das klppt nicht so richtig kann mir jemand...

  1. Hallo zusammen
    Ich versucht mich mal in der Benutzung von userfroms aber das klppt nicht so richtig kann mir jemand mal auf die sprünge helfen wie ich zum Beispiel einen Abbruch des Programms erzeugen kann?

    Hier konkreter:

    auf dem User Form gibt es ein paar check Boxes die bei eienem CommandButtonOK ausgeführt werden, wenn diese Markiert waren.
    Es soll aber noch einen Abbruch geben das egal was markiert ist der Makro nicht mehr ausgeführt werden soll.

    Kann mir jemand verraten wie das geht?

    Gruss Simdipl
     
  2. Hallo simdipl,

    wenn Du eine Userform1 aufrufst, passiert das meist mit
    Code:
    ....
    Load Userfrom1
    Userform1.Show
    ....
    'Rückgabewerte verarbeiten
    Dann wird die Userform1 sichtbar.

    Wenn der CommandButton1 die OK Taste ist, könnte das Click-Ereignis dafür folgendermassen aussehen:

    Code:
    Private Sub CommandButton1_Click
    
       '... prüfen, ob alle Eingaben ok
    
       If no ok then
       'wenn nein, Fehlermeldung und wieder in die Form
       Msgbox(...)
       Exit sub
       
       Else
       'wenn alles ok
       'Rückgabewerte in globale Variablen speichern
       
       End IF
    End Sub
    Wenn der Abbruch-Button der CommandButton2 ist:
    Code:
    Private Sub CommandButton2_Click
       'Form entladen
       Unload Userform1 
    End Sub
    Gruß Matjes :)
     
  3. Hi Matjes

    Vielen Dank das funktioniert nun aber ich habe noch zwei probleme.
    Ich wollte hinter die CheckBox ein Sub legen das dann aufgerufen wird sofern das Häckchen gesetzt wurde.

    ein beispiel:
    If CheckBox1_Click Then
    Modul11.sortieren
    End If
    Das geht übrigens nicht!

    Und mein zweites Problem ist wie bekomme ich eine Auswahl liste aus der man sich eine Zahl aussuchen kann in einem UserForm aufgerufen.
    Ich habe versucht es aus einem Beispiel abzuleiten aber das funktioneit ganz und gar nicht.

    auch hier ein Beispiel:


    Private Sub UserForm2_Initialize()
    Label1.Left = 18
    Label1.Top = 12
    Label1.Height = 12
    Label1.Width = 190
    Label1.Caption = Select picture placement _
    & relative to the caption.

    ->Add list entries to combo box. The value of each
    ->entry matches the corresponding ListIndex value
    ->in the combo box.
    ComboBox1.AddItem 601 ->ListIndex = 0
    ComboBox1.AddItem 602 ->ListIndex = 1
    ComboBox1.AddItem 604 ->ListIndex = 2
    ComboBox1.AddItem 605 ->ListIndex = 3
    ComboBox1.AddItem 608 ->ListIndex = 4
    ComboBox1.AddItem 609 ->ListIndex = 5
    ComboBox1.AddItem 617 ->ListIndex = 6
    ComboBox1.AddItem 618 ->ListIndex = 7
    ComboBox1.AddItem 701 ->ListIndex = 8
    ComboBox1.AddItem 702 ->ListIndex = 9
    ComboBox1.AddItem 703 ->ListIndex = 10
    ComboBox1.AddItem 704 ->ListIndex = 11
    ComboBox1.AddItem Centered ->ListIndex = 12
    ->Use drop-down list
    ComboBox1.Style = fmStyleDropDownList
    ->Combo box values are ListIndex values
    ComboBox1.BoundColumn = 0
    ->Set combo box to first entry
    ComboBox1.ListIndex = 0
    ->Use drop-down list
    ComboBox1.Style = fmStyleDropDownList
    ->Combo box values are ListIndex values
    ComboBox1.BoundColumn = 0
    ->Set combo box to first entry
    ComboBox1.ListIndex = 0


    ComboBox1.Left = 18
    ComboBox1.Top = 36
    ComboBox1.Width = 90
    ComboBox1.ListWidth = 90

    ->Initialize CommandButton1
    CommandButton1.Left = 230
    CommandButton1.Top = 36
    CommandButton1.Height = 120
    CommandButton1.Width = 120



    End Sub

    Private Sub ComboBox1_Initialize()
    Select Case ComboBox1.Value
    Case 0->Left Top
    s1 = ComboBox1.Value
    s2 = dry
    s3 = 8
    s4 = 1.1
    s5 = 30
    s6 = 0.048
    s7 = Dauer
    s8 = 50

    Case 1->Left Center
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = tiles
    Worksheets(1).Cells(2, 8).Value = 4
    Worksheets(1).Cells(2, 9).Value = 0.4
    Worksheets(1).Cells(2, 10).Value = 30
    Worksheets(1).Cells(2, 11).Value = 0.068
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50
    Case 2->Left Bottom
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = snow
    Worksheets(1).Cells(2, 8).Value = 3
    Worksheets(1).Cells(2, 9).Value = 0.3
    Worksheets(1).Cells(2, 10).Value = 30
    Worksheets(1).Cells(2, 11).Value = 0.068
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50
    Case 3->Right Top
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = ice
    Worksheets(1).Cells(2, 8).Value = 1
    Worksheets(1).Cells(2, 9).Value = 0.1
    Worksheets(1).Cells(2, 10).Value = 30
    Worksheets(1).Cells(2, 11).Value = 0.068
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50

    Case 4->Right Center
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = dry
    Worksheets(1).Cells(2, 8).Value = dv
    Worksheets(1).Cells(2, 9).Value = mueWert
    Worksheets(1).Cells(2, 10).Value = 60
    Worksheets(1).Cells(2, 11).Value = 0.13
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50


    Case 5->Right Bottom
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = tiles
    Worksheets(1).Cells(2, 8).Value = dv
    Worksheets(1).Cells(2, 9).Value = mueWert
    Worksheets(1).Cells(2, 10).Value = 60
    Worksheets(1).Cells(2, 11).Value = 0.29
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50

    Case 6->Above Left
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = snow
    Worksheets(1).Cells(2, 8).Value = 3
    Worksheets(1).Cells(2, 9).Value = 0.3
    Worksheets(1).Cells(2, 10).Value = 100
    Worksheets(1).Cells(2, 11).Value = 0.29
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50

    Case 7->Above Center
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = ice
    Worksheets(1).Cells(2, 8).Value = 1
    Worksheets(1).Cells(2, 9).Value = 0.1
    Worksheets(1).Cells(2, 10).Value = 100
    Worksheets(1).Cells(2, 11).Value = datdis
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50

    Case 8->Above Right
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = dry
    Worksheets(1).Cells(2, 8).Value = 8
    Worksheets(1).Cells(2, 9).Value = 1.1
    Worksheets(1).Cells(2, 10).Value = 100
    Worksheets(1).Cells(2, 11).Value = 0.29
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50

    Case 9->Below Left
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = wet
    Worksheets(1).Cells(2, 8).Value = 6
    Worksheets(1).Cells(2, 9).Value = 0.95
    Worksheets(1).Cells(2, 10).Value = 100
    Worksheets(1).Cells(2, 11).Value = 0.13
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50

    Case 10->Below Right
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = snow
    Worksheets(1).Cells(2, 8).Value = 4
    Worksheets(1).Cells(2, 9).Value = 0.4
    Worksheets(1).Cells(2, 10).Value = 60
    Worksheets(1).Cells(2, 11).Value = 0.13
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50

    Case 11->Below Center
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = dry
    Worksheets(1).Cells(2, 8).Value = 8
    Worksheets(1).Cells(2, 9).Value = 1.1
    Worksheets(1).Cells(2, 10).Value = 60
    Worksheets(1).Cells(2, 11).Value = 0.13
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50


    Case 12->Centered
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = mue Type
    Worksheets(1).Cells(2, 8).Value = dv
    Worksheets(1).Cells(2, 9).Value = mueWert
    Worksheets(1).Cells(2, 10).Value = Km/h
    Worksheets(1).Cells(2, 11).Value = datdis
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50

    End Select
    -> CommandButton1_Click s1, s2, s3, s4, s5, s6, s7, s8

    Worksheets(1).Cells(2, 6).Value = s1
    Worksheets(1).Cells(2, 7).Value = s2
    Worksheets(1).Cells(2, 8).Value = s3
    Worksheets(1).Cells(2, 9).Value = s4
    Worksheets(1).Cells(2, 10).Value = s5
    Worksheets(1).Cells(2, 11).Value = s6
    Worksheets(1).Cells(2, 12).Value = s7
    Worksheets(1).Cells(2, 13).Value = s8


    End Sub

    End Sub

    Private Sub CommandButton1_Click()->(s1, s2, s3, s4, s5, s6, s7, s8)

    Worksheets(1).Cells(1, 6).Value = #
    Worksheets(1).Cells(1, 7).Value = mue Type
    Worksheets(1).Cells(1, 8).Value = dv
    Worksheets(1).Cells(1, 9).Value = mueWert
    Worksheets(1).Cells(1, 10).Value = Km/h
    Worksheets(1).Cells(1, 11).Value = datdis
    Worksheets(1).Cells(1, 12).Value = Dauer
    Worksheets(1).Cells(1, 13).Value = Messungen

    Worksheets(1).Cells(2, 6).Value = s1
    Worksheets(1).Cells(2, 7).Value = s2
    Worksheets(1).Cells(2, 8).Value = s3
    Worksheets(1).Cells(2, 9).Value = s4
    Worksheets(1).Cells(2, 10).Value = s5
    Worksheets(1).Cells(2, 11).Value = s6
    Worksheets(1).Cells(2, 12).Value = s7
    Worksheets(1).Cells(2, 13).Value = s8

    ComboBox1.Value = Worksheets(1).Cells(2, 6).Value

    UserForm2.Hide
    End Sub

    Private Sub UserForm2_Click()

    End Sub

    Private Sub UserForm_Click()
    Select Case ComboBox1.Value
    Case 0->Left Top
    s1 = ComboBox1.Value
    s2 = dry
    s3 = 8
    s4 = 1.1
    s5 = 30
    s6 = 0.048
    s7 = Dauer
    s8 = 50

    Case 1->Left Center
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = tiles
    Worksheets(1).Cells(2, 8).Value = 4
    Worksheets(1).Cells(2, 9).Value = 0.4
    Worksheets(1).Cells(2, 10).Value = 30
    Worksheets(1).Cells(2, 11).Value = 0.068
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50
    Case 2->Left Bottom
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = snow
    Worksheets(1).Cells(2, 8).Value = 3
    Worksheets(1).Cells(2, 9).Value = 0.3
    Worksheets(1).Cells(2, 10).Value = 30
    Worksheets(1).Cells(2, 11).Value = 0.068
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50
    Case 3->Right Top
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = ice
    Worksheets(1).Cells(2, 8).Value = 1
    Worksheets(1).Cells(2, 9).Value = 0.1
    Worksheets(1).Cells(2, 10).Value = 30
    Worksheets(1).Cells(2, 11).Value = 0.068
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50

    Case 4->Right Center
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = dry
    Worksheets(1).Cells(2, 8).Value = dv
    Worksheets(1).Cells(2, 9).Value = mueWert
    Worksheets(1).Cells(2, 10).Value = 60
    Worksheets(1).Cells(2, 11).Value = 0.13
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50


    Case 5->Right Bottom
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = tiles
    Worksheets(1).Cells(2, 8).Value = dv
    Worksheets(1).Cells(2, 9).Value = mueWert
    Worksheets(1).Cells(2, 10).Value = 60
    Worksheets(1).Cells(2, 11).Value = 0.29
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50

    Case 6->Above Left
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = snow
    Worksheets(1).Cells(2, 8).Value = 3
    Worksheets(1).Cells(2, 9).Value = 0.3
    Worksheets(1).Cells(2, 10).Value = 100
    Worksheets(1).Cells(2, 11).Value = 0.29
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50

    Case 7->Above Center
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = ice
    Worksheets(1).Cells(2, 8).Value = 1
    Worksheets(1).Cells(2, 9).Value = 0.1
    Worksheets(1).Cells(2, 10).Value = 100
    Worksheets(1).Cells(2, 11).Value = datdis
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50

    Case 8->Above Right
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = dry
    Worksheets(1).Cells(2, 8).Value = 8
    Worksheets(1).Cells(2, 9).Value = 1.1
    Worksheets(1).Cells(2, 10).Value = 100
    Worksheets(1).Cells(2, 11).Value = 0.29
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50

    Case 9->Below Left
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = wet
    Worksheets(1).Cells(2, 8).Value = 6
    Worksheets(1).Cells(2, 9).Value = 0.95
    Worksheets(1).Cells(2, 10).Value = 100
    Worksheets(1).Cells(2, 11).Value = 0.13
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50

    Case 10->Below Right
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = snow
    Worksheets(1).Cells(2, 8).Value = 4
    Worksheets(1).Cells(2, 9).Value = 0.4
    Worksheets(1).Cells(2, 10).Value = 60
    Worksheets(1).Cells(2, 11).Value = 0.13
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50

    Case 11->Below Center
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = dry
    Worksheets(1).Cells(2, 8).Value = 8
    Worksheets(1).Cells(2, 9).Value = 1.1
    Worksheets(1).Cells(2, 10).Value = 60
    Worksheets(1).Cells(2, 11).Value = 0.13
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50


    Case 12->Centered
    Worksheets(1).Cells(2, 6).Value = ComboBox1.Value
    Worksheets(1).Cells(2, 7).Value = mue Type
    Worksheets(1).Cells(2, 8).Value = dv
    Worksheets(1).Cells(2, 9).Value = mueWert
    Worksheets(1).Cells(2, 10).Value = Km/h
    Worksheets(1).Cells(2, 11).Value = datdis
    Worksheets(1).Cells(2, 12).Value = Dauer
    Worksheets(1).Cells(2, 13).Value = 50

    End Select
    -> CommandButton1_Click s1, s2, s3, s4, s5, s6, s7, s8

    Worksheets(1).Cells(2, 6).Value = s1
    Worksheets(1).Cells(2, 7).Value = s2
    Worksheets(1).Cells(2, 8).Value = s3
    Worksheets(1).Cells(2, 9).Value = s4
    Worksheets(1).Cells(2, 10).Value = s5
    Worksheets(1).Cells(2, 11).Value = s6
    Worksheets(1).Cells(2, 12).Value = s7
    Worksheets(1).Cells(2, 13).Value = s8


    End Sub

    End Sub
    End Sub

    ich hoffe du kanns mir weiter helfen

    Danke schonmal für das erste Problem

    Gruß Simdipl
     
  4. Hallo Simdipl,

    schick mir mal an meinen mailaddy deine mail-Adresse. Dann schick ich dir ein kleines Beispiel, in dem du deine Fragen beantwortet findest.

    Gruß Matjes :)
     
  5. Hi Matjes
    ich habe die Adresse nicht gefunden deswegen so

    mnmue(ät)web.de(Adresse wegen spam sicherheitshalber verändert)

    Gruß simdipl
     
  6. ist unterwegs  ;D

    Wenn du dich als User einlogst,  sollte unter meinem Namen ein Briefumschlag zu sehen sein. Wenn du da mit der Maus drauf gehst, geht ein mail an mich auf.

    Gruß Matjes :)
     
Die Seite wird geladen...

userform benutzung - Ähnliche Themen

Forum Datum
Re: Excel - Hilfe bei Datenstruktur für spätere UserForm Windows XP Forum 6. Aug. 2010
Wenn-Dann-Sonst Funktion in Userform Microsoft Office Suite 26. Mai 2005
Daten aus Userform in Tabelle Microsoft Office Suite 22. Mai 2005
Farben in UserForm (Word97) Microsoft Office Suite 19. Sep. 2004
Gleichzeitige Benutzung von Tastatur und Maus hängt PC auf Windows 7 Forum 5. Feb. 2016