Thema Datum  Von Nutzer Rating
Antwort
Rot VBA
25.09.2012 09:39:41 Niklas
NotSolved
Blau VBA
25.09.2012 11:23:30 ferdi
NotSolved
Rot VBA
25.09.2012 13:07:35 Dekor
NotSolved
Blau VBA
25.09.2012 14:37:40 Niklas
NotSolved
Rot VBA
26.09.2012 12:26:28 Dekor
*****
NotSolved
Blau VBA
26.09.2012 12:39:43 Niklas
NotSolved
Rot VBA
26.09.2012 12:53:42 Dekor
NotSolved
Blau VBA
26.09.2012 12:58:04 Niklas
NotSolved
Rot VBA
26.09.2012 13:04:19 Gast14507
NotSolved
Blau VBA
26.09.2012 13:36:09 Niklas
NotSolved
Rot VBA
26.09.2012 20:39:20 Till
NotSolved
Blau VBA
26.09.2012 20:24:58 Dekor
NotSolved
Rot VBA
26.09.2012 20:29:25 Dekor
NotSolved
Blau VBA
26.09.2012 20:50:48 Till
NotSolved
Rot VBA
26.09.2012 21:23:44 Dekor
NotSolved
Blau VBA
27.09.2012 10:05:25 Niklas
NotSolved
Rot VBA
27.09.2012 11:10:10 Till
NotSolved
Blau VBA
27.09.2012 12:32:19 Dekor
NotSolved
Rot VBA
27.09.2012 12:35:04 Dekor
NotSolved
Blau VBA
27.09.2012 13:19:49 Gast88555
NotSolved
Rot VBA
27.09.2012 13:22:02 Niklas
NotSolved
Blau VBA
27.09.2012 16:24:11 Till
NotSolved
Rot VBA
27.09.2012 17:58:26 Niklas
NotSolved
Blau VBA
27.09.2012 18:28:25 Till
NotSolved
Rot VBA
27.09.2012 18:38:03 Niklas
NotSolved
Blau VBA
27.09.2012 18:45:06 Niklas
NotSolved
Rot VBA
27.09.2012 21:23:18 Till
NotSolved
Blau VBA
28.09.2012 09:12:08 Niklas
NotSolved
Rot VBA
28.09.2012 12:42:03 Gast43175
NotSolved
Blau VBA
28.09.2012 09:10:04 Niklas
NotSolved
Rot VBA
28.09.2012 18:17:37 Till
NotSolved
Blau VBA
28.09.2012 19:24:30 Niklas
NotSolved
Rot VBA
28.09.2012 21:16:06 Till
NotSolved
Blau VBA
10.10.2012 11:13:24 Niklas
NotSolved
Rot VBA
11.10.2012 09:27:58 Niklas
NotSolved
Blau VBA
10.10.2012 11:47:12 Gast884
NotSolved
Rot VBA
11.10.2012 06:13:51 Till
NotSolved
Blau VBA
11.10.2012 08:50:55 Niklas
NotSolved
Rot VBA
11.10.2012 09:15:51 Niklas
NotSolved
Blau VBA
12.10.2012 23:55:02 Till
NotSolved
Rot VBA
13.10.2012 22:39:06 Niklas
NotSolved
Blau VBA
14.10.2012 23:47:49 Till
NotSolved
Rot VBA
15.10.2012 09:19:00 Niklas
NotSolved
Blau VBA
15.10.2012 11:34:04 Till
NotSolved
Rot VBA
15.10.2012 13:40:41 Niklas
NotSolved
Blau VBA
15.10.2012 15:15:20 Niklas
NotSolved
Rot VBA
15.10.2012 20:20:40 Till
NotSolved
Blau Blau VBA
15.10.2012 20:25:39 Niklas
NotSolved

Ansicht des Beitrags:
Von:
Till
Datum:
27.09.2012 18:28:25
Views:
1470
Rating: Antwort:
  Ja
Thema:
VBA

Hi,

also ich habe mal deine Module von 22 auf 4 reduziert:

Kontrollmodul zum laden der Userform mit verschiedenen Parametern (aKontrollmodul):

Hier kannst du Parameter eingeben/verändern und erweitern.

Option Explicit
Sub EingabeStarten() '*Userform über dieses Makro aufrufen!
    ShowForm
End Sub
Sub ShowForm(Optional ByVal Index As Integer = 0)
Load UF_Tabelle
Dim Parameter(10) As New UFParameter
Dim Start%, Sh As Worksheet
    
    'Startblatt
        Start = Sheets("GSP ORR PKW intern gesamt").Index
    
    'verschiedene Parameter
        With Parameter(0)
            Set Sh = Sheets(Start)
            Set .Bereich = Sh.Range("E28:G31")
            .TitelText = Sh.Range("B36")
            .TextBoxBereich = "2-13"
        End With
        With Parameter(1)
            Set Sh = Sheets(Start + 1)
            Set .Bereich = Sh.Range("E28:G31")
            .TitelText = Sh.Range("B36")
            .TextBoxBereich = "2-13"
        End With
        With Parameter(2)
            'hier erweitern
        End With
        '...
        
    'Auswahl Blatt
        If Index > UBound(Parameter) Then Index = 0 'Anzahl Blätter
        With UF_Tabelle
            Set .aVorgegebenerBereich = Parameter(Index).Bereich
            .aTitelZelle = Parameter(Index).TitelText
            .aIndex = Index
            .aTextBoxBereich = Parameter(Index).TextBoxBereich
        End With
    
    'Initialisieren & Anzeigen
        With UF_Tabelle
            .Caption = "Checkliste C Befüllung" & " - Blatt " & Index & "/10"
            .Initialize
            .Show
        End With
End Sub

Klassenmodul für den Umgang mit den Textboxen (Datentransfer):

Option Explicit
 
Private Zellen() As Range
Private Controls() As Control
 
Public Bereich As Range
Public UF As UserForm
Public ControlType As String
 
Sub ZellenEinlesen(rng As Range)
    Dim E1%, E2%
     
    Set Bereich = rng
    If Bereich Is Nothing Then Exit Sub
    With Bereich
        E1 = .Rows.Count
        E2 = .Columns.Count
    End With
     
    ReDim Zellen(E1 * E2 - 1)
    Dim r%, c%, i%
    For r = 1 To E1
        For c = 1 To E2
            Set Zellen(i) = Bereich(r, c)
            i = i + 1
        Next
    Next
End Sub
Sub ControlsEinlesen(ControlNames As String)
    Dim Arr
    Dim E1%, E2%, i%
     
    If InStr(ControlNames, "-") Then
        Arr = Split(ControlNames, "-")
        If UBound(Arr) = 1 Then
            If IsNumeric(Arr(0)) Then
                E1 = Arr(0)
                If IsNumeric(Arr(1)) Then
                    E2 = Arr(1)
                Else: Exit Sub
                End If
            Else: Exit Sub
            End If
            ReDim Controls(E2 - E1)
            Dim j%
            For i = E1 To E2
                Set Controls(j) = UF.Controls(ControlType & i)
                j = j + 1
            Next
        End If
    ElseIf InStr(ControlNames, ",") Then
        Arr = Split(ControlNames, ",")
        E2 = UBound(Arr)
        ReDim Controls(E2)
        For i = 0 To E2
            Set Controls(i) = UF.Controls(ControlType & Arr(i))
        Next
    End If
End Sub
 
Sub Import()
If Not IsArray(Controls) Then Exit Sub
    Dim i%
    For i = 0 To UBound(Controls)
        Controls(i).Text = Zellen(i)
    Next
End Sub
Sub Export()
If Not IsArray(Controls) Then Exit Sub
    Dim i%
    For i = 0 To UBound(Controls)
        Zellen(i) = Controls(i).Text
    Next
End Sub
Function Überprüfen() As Boolean
If Not IsArray(Controls) Then Exit Sub
    Dim X
    For Each X In Controls
        If X.Text = "" Then
            MsgBox "Bitte " & X.Name & " ausfüllen!"
            Exit Function
        End If
    Next
    Überprüfen = True
End Function
Sub SteuerelementeResetten()
If Not IsArray(Controls) Then Exit Sub
    Dim X
    For Each X In Controls
        X.Text = ""
    Next
End Sub

Klassenmodul für Userform Parameter (UFParameter):

Public Bereich As Range
Public TextBoxBereich As String
Public TitelText As String

Und etwas veränderte Userform (UF_Tabelle):

Option Explicit

'Public
Public aVorgegebenerBereich As Range
Public aTitelZelle As String
Public aTextBoxBereich As String
Public aIndex%

'Initialisieren
Dim ZielBlatt As Worksheet
Dim DT As New Datentransfer
Sub Initialize()
    If aVorgegebenerBereich Is Nothing Or aTextBoxBereich = "" Then
        NewInput
        Exit Sub
    End If
    aVorgegebenerBereich.Parent.Activate
    With DT
        Set .UF = Me
        .ZellenEinlesen aVorgegebenerBereich
        .ControlType = "TextBox"
        .ControlsEinlesen aTextBoxBereich
        .Import
    End With
End Sub
Private Sub UserForm_Activate()
    'Erstes Auswahlfeld Markieren
    With TextBox2
        .SetFocus
        .SelStart = 0
        .SelLength = Len(.Text)
    End With
    'Überschrift
    Me.TextBox1.Value = aTitelZelle
End Sub

'Schalter
Private Sub cmdSave_Click()
    With DT
        .ControlsEinlesen aTextBoxBereich
        If .Überprüfen Then
            .ControlsEinlesen aTextBoxBereich
            .Export
        End If
    End With
End Sub
Private Sub cmdNewInput_Click()
    NewInput
End Sub
Private Sub cmdAbort_Click()
    Unload Me
End Sub
Private Sub cmdReset_Click()
    DT.Bereich = 0
    Unload Me
    UF_Tabelle.Show 'hier eintragen
End Sub

'Eingabekontrolle
Private Sub TextBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    Check ActiveControl, KeyAscii
End Sub
Private Sub TextBox3_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    Check ActiveControl, KeyAscii
End Sub
Private Sub TextBox4_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    Check ActiveControl, KeyAscii
End Sub
Private Sub TextBox5_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    Check ActiveControl, KeyAscii
End Sub
Private Sub TextBox6_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    Check ActiveControl, KeyAscii
End Sub
Private Sub TextBox7_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    Check ActiveControl, KeyAscii
End Sub
Private Sub TextBox8_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    Check ActiveControl, KeyAscii
End Sub
Private Sub TextBox9_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    Check ActiveControl, KeyAscii
End Sub
Private Sub TextBox10_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    Check ActiveControl, KeyAscii
End Sub
Private Sub TextBox11_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    Check ActiveControl, KeyAscii
End Sub
Private Sub TextBox12_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    Check ActiveControl, KeyAscii
End Sub
Private Sub TextBox13_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    Check ActiveControl, KeyAscii
End Sub

'*****************
'*Hilfsfunktionen*
'*****************
Private Sub NewInput()
    Set aVorgegebenerBereich = Nothing
    aTitelZelle = ""
    aTextBoxBereich = ""
    DT.SteuerelementeResetten
    ShowForm aIndex + 1
End Sub
'check if value is numeric and stop if it isnt
Private Sub Check(ctr As Control, Key As MSForms.ReturnInteger)
    Dim str As String
    If TypeOf ActiveControl Is Frame Then
        str = Controls(Me.ActiveControl.Name).ActiveControl.Text
    Else
        str = ActiveControl.Text
    End If
    If Not IsNumeric(str & Chr(Key)) Then
        Key = 0
        Beep
    End If
End Sub

'kann nach belieben alle zulässigen Controls anwählen
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    Dim ctr As Control
    For Each ctr In Me.Controls
        Dim cX%, cY%
        With ctr
            If X >= .Left - 1 And X <= .Left + .Width + 1 Then
                If Y >= .Top - 1 And Y <= .Top + .Height + 1 Then
                    If InStr(ctr.Name, "cmd") > 0 Then
                        ctr.SetFocus
                    End If
                End If
            End If
        End With
    Next
End Sub

Und hier die ganze Datei (Musste sie als .xls bearbeiten, solltest du aber auch mit 2007/2010 bearbeiten/konvertieren können):

http://www.yourfilelink.com/get.php?fid=821881

 

Gruß

Till


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
Rot VBA
25.09.2012 09:39:41 Niklas
NotSolved
Blau VBA
25.09.2012 11:23:30 ferdi
NotSolved
Rot VBA
25.09.2012 13:07:35 Dekor
NotSolved
Blau VBA
25.09.2012 14:37:40 Niklas
NotSolved
Rot VBA
26.09.2012 12:26:28 Dekor
*****
NotSolved
Blau VBA
26.09.2012 12:39:43 Niklas
NotSolved
Rot VBA
26.09.2012 12:53:42 Dekor
NotSolved
Blau VBA
26.09.2012 12:58:04 Niklas
NotSolved
Rot VBA
26.09.2012 13:04:19 Gast14507
NotSolved
Blau VBA
26.09.2012 13:36:09 Niklas
NotSolved
Rot VBA
26.09.2012 20:39:20 Till
NotSolved
Blau VBA
26.09.2012 20:24:58 Dekor
NotSolved
Rot VBA
26.09.2012 20:29:25 Dekor
NotSolved
Blau VBA
26.09.2012 20:50:48 Till
NotSolved
Rot VBA
26.09.2012 21:23:44 Dekor
NotSolved
Blau VBA
27.09.2012 10:05:25 Niklas
NotSolved
Rot VBA
27.09.2012 11:10:10 Till
NotSolved
Blau VBA
27.09.2012 12:32:19 Dekor
NotSolved
Rot VBA
27.09.2012 12:35:04 Dekor
NotSolved
Blau VBA
27.09.2012 13:19:49 Gast88555
NotSolved
Rot VBA
27.09.2012 13:22:02 Niklas
NotSolved
Blau VBA
27.09.2012 16:24:11 Till
NotSolved
Rot VBA
27.09.2012 17:58:26 Niklas
NotSolved
Blau VBA
27.09.2012 18:28:25 Till
NotSolved
Rot VBA
27.09.2012 18:38:03 Niklas
NotSolved
Blau VBA
27.09.2012 18:45:06 Niklas
NotSolved
Rot VBA
27.09.2012 21:23:18 Till
NotSolved
Blau VBA
28.09.2012 09:12:08 Niklas
NotSolved
Rot VBA
28.09.2012 12:42:03 Gast43175
NotSolved
Blau VBA
28.09.2012 09:10:04 Niklas
NotSolved
Rot VBA
28.09.2012 18:17:37 Till
NotSolved
Blau VBA
28.09.2012 19:24:30 Niklas
NotSolved
Rot VBA
28.09.2012 21:16:06 Till
NotSolved
Blau VBA
10.10.2012 11:13:24 Niklas
NotSolved
Rot VBA
11.10.2012 09:27:58 Niklas
NotSolved
Blau VBA
10.10.2012 11:47:12 Gast884
NotSolved
Rot VBA
11.10.2012 06:13:51 Till
NotSolved
Blau VBA
11.10.2012 08:50:55 Niklas
NotSolved
Rot VBA
11.10.2012 09:15:51 Niklas
NotSolved
Blau VBA
12.10.2012 23:55:02 Till
NotSolved
Rot VBA
13.10.2012 22:39:06 Niklas
NotSolved
Blau VBA
14.10.2012 23:47:49 Till
NotSolved
Rot VBA
15.10.2012 09:19:00 Niklas
NotSolved
Blau VBA
15.10.2012 11:34:04 Till
NotSolved
Rot VBA
15.10.2012 13:40:41 Niklas
NotSolved
Blau VBA
15.10.2012 15:15:20 Niklas
NotSolved
Rot VBA
15.10.2012 20:20:40 Till
NotSolved
Blau Blau VBA
15.10.2012 20:25:39 Niklas
NotSolved