Thema Datum  Von Nutzer Rating
Antwort
26.05.2016 15:30:34 Sdravi
NotSolved
26.05.2016 17:51:51 Gast71200
NotSolved
Rot UserForm Daten auslesen und anzeigen
26.05.2016 20:03:30 Gast16080
NotSolved
26.05.2016 22:04:16 Gast77476
NotSolved
27.05.2016 04:38:08 Gast49651
NotSolved
27.05.2016 18:39:40 Gast39404
NotSolved
27.05.2016 19:28:19 Gast31470
Solved
29.05.2016 15:09:12 Gast11855
NotSolved
29.05.2016 16:10:11 Gast69544
NotSolved

Ansicht des Beitrags:
Von:
Gast16080
Datum:
26.05.2016 20:03:30
Views:
913
Rating: Antwort:
  Ja
Thema:
UserForm Daten auslesen und anzeigen

Hy mein VBA ist miserabel :-(

zurzeit habe ich das hier das reicht aber noch nicht aus

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
Option Explicit
 
Private Const ROOT_FOLDER As String = "C:\Users\asus\Desktop\excel\"
 
Private Sub CommandButton1_Click()
     
    Dim objWorbook As Workbook
     
    If ComboBox1.ListIndex > -1 Then
         
        With Application
            .Calculation = xlCalculationManual
            .EnableEvents = False
            .ScreenUpdating = False
        End With
         
        Set objWorbook = Workbooks.Open(Filename:= _
            ROOT_FOLDER & ComboBox1.Text, UpdateLinks:=0, ReadOnly:=True)
         
        Call objWorbook.Worksheets(1).Range("A3:F3").Copy( _
            Destination:=ThisWorkbook.Worksheets(1).Cells(4, 1))
         
        Call objWorbook.Close(SaveChanges:=False)
         
        Set objWorbook = Nothing
         
        With Application
            .Calculation = xlCalculationAutomatic
            .EnableEvents = True
            .ScreenUpdating = True
        End With
    End If
     
     If ComboBox2.ListIndex > -1 Then
         
        With Application
            .Calculation = xlCalculationManual
            .EnableEvents = False
            .ScreenUpdating = False
        End With
         
        Set objWorbook = Workbooks.Open(Filename:= _
            ROOT_FOLDER & ComboBox2.Text, UpdateLinks:=0, ReadOnly:=True)
         
        Call objWorbook.Worksheets(1).Range("A3:F3").Copy( _
            Destination:=ThisWorkbook.Worksheets(1).Cells(5, 1))
         
        Call objWorbook.Close(SaveChanges:=False)
         
        Set objWorbook = Nothing
         
        With Application
            .Calculation = xlCalculationAutomatic
            .EnableEvents = True
            .ScreenUpdating = True
        End With
    End If
     
    If ComboBox3.ListIndex > -1 Then
         
        With Application
            .Calculation = xlCalculationManual
            .EnableEvents = False
            .ScreenUpdating = False
        End With
         
        Set objWorbook = Workbooks.Open(Filename:= _
            ROOT_FOLDER & ComboBox3.Text, UpdateLinks:=0, ReadOnly:=True)
         
        Call objWorbook.Worksheets(1).Range("A3:F3").Copy( _
            Destination:=ThisWorkbook.Worksheets(1).Cells(6, 1))
         
        Call objWorbook.Close(SaveChanges:=False)
         
        Set objWorbook = Nothing
         
        With Application
            .Calculation = xlCalculationAutomatic
            .EnableEvents = True
            .ScreenUpdating = True
        End With
    End If
     
    If ComboBox4.ListIndex > -1 Then
         
        With Application
            .Calculation = xlCalculationManual
            .EnableEvents = False
            .ScreenUpdating = False
        End With
         
        Set objWorbook = Workbooks.Open(Filename:= _
            ROOT_FOLDER & ComboBox4.Text, UpdateLinks:=0, ReadOnly:=True)
         
        Call objWorbook.Worksheets(1).Range("A3:F3").Copy( _
            Destination:=ThisWorkbook.Worksheets(1).Cells(7, 1))
         
        Call objWorbook.Close(SaveChanges:=False)
         
        Set objWorbook = Nothing
         
        With Application
            .Calculation = xlCalculationAutomatic
            .EnableEvents = True
            .ScreenUpdating = True
        End With
    End If
     
    If ComboBox5.ListIndex > -1 Then
         
        With Application
            .Calculation = xlCalculationManual
            .EnableEvents = False
            .ScreenUpdating = False
        End With
         
        Set objWorbook = Workbooks.Open(Filename:= _
            ROOT_FOLDER & ComboBox5.Text, UpdateLinks:=0, ReadOnly:=True)
         
        Call objWorbook.Worksheets(1).Range("A3:F3").Copy( _
            Destination:=ThisWorkbook.Worksheets(1).Cells(8, 1))
         
        Call objWorbook.Close(SaveChanges:=False)
         
        Set objWorbook = Nothing
         
        With Application
            .Calculation = xlCalculationAutomatic
            .EnableEvents = True
            .ScreenUpdating = True
        End With
    End If
     
    If ComboBox6.ListIndex > -1 Then
         
        With Application
            .Calculation = xlCalculationManual
            .EnableEvents = False
            .ScreenUpdating = False
        End With
         
        Set objWorbook = Workbooks.Open(Filename:= _
            ROOT_FOLDER & ComboBox6.Text, UpdateLinks:=0, ReadOnly:=True)
         
        Call objWorbook.Worksheets(1).Range("A3:F3").Copy( _
            Destination:=ThisWorkbook.Worksheets(1).Cells(9, 1))
         
        Call objWorbook.Close(SaveChanges:=False)
         
        Set objWorbook = Nothing
         
        With Application
            .Calculation = xlCalculationAutomatic
            .EnableEvents = True
            .ScreenUpdating = True
        End With
    End If
End Sub
 
Private Sub CommandButton2_Click()
    Call Unload(Me)
End Sub
 
Private Sub UserForm_Activate()
     
    Dim strFilename As String
     
    strFilename = Dir$(ROOT_FOLDER & "*.xls")
     
    Do Until strFilename = vbNullString
         
        Call ComboBox1.AddItem(pvargItem:=strFilename)
        Call ComboBox2.AddItem(pvargItem:=strFilename)
        Call ComboBox3.AddItem(pvargItem:=strFilename)
        Call ComboBox4.AddItem(pvargItem:=strFilename)
        Call ComboBox5.AddItem(pvargItem:=strFilename)
        Call ComboBox6.AddItem(pvargItem:=strFilename)
        strFilename = Dir$
         
    Loop
End Sub

Ich habe in den Dateien immer 6 Tabellen jetzt mochte ich im UserForm 6 OptionButtons einbauen um dan auszuwählen aus welcher Tabele er mir die Daten zeigen soll.

Und der Obere Code geht bestimmt auch schlanker oder?

 

mfg

 


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
26.05.2016 15:30:34 Sdravi
NotSolved
26.05.2016 17:51:51 Gast71200
NotSolved
Rot UserForm Daten auslesen und anzeigen
26.05.2016 20:03:30 Gast16080
NotSolved
26.05.2016 22:04:16 Gast77476
NotSolved
27.05.2016 04:38:08 Gast49651
NotSolved
27.05.2016 18:39:40 Gast39404
NotSolved
27.05.2016 19:28:19 Gast31470
Solved
29.05.2016 15:09:12 Gast11855
NotSolved
29.05.2016 16:10:11 Gast69544
NotSolved