Thema Datum  Von Nutzer Rating
Antwort
15.04.2015 15:42:50 Sven
NotSolved
15.04.2015 15:43:23 Gast82889
NotSolved
Rot Lagerverwaltung über Userform
15.04.2015 17:26:14 Sven
NotSolved
15.04.2015 17:49:39 Sven
NotSolved

Ansicht des Beitrags:
Von:
Sven
Datum:
15.04.2015 17:26:14
Views:
2305
Rating: Antwort:
  Ja
Thema:
Lagerverwaltung über Userform

So nochmal ein Versuch den Code einzufügen

Also folgende Probleme hab ich. Die Userform entlädt sich jedesmal wenn ein Datensatz gelöscht wird.

Dazu kommt das die Preise die ich zwar über die Userform eintragen kann nicht über die Listbox ausgegeben werden sondern lediglich die Zeile des Datensatzes angezeigt wird.


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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
Option Explicit
 
'
'    Exit-Button
'
Private Sub CommandButton6_Click()
 
   Unload UserForm1
 
End Sub
 
 
Private Sub Image1_Click()
 
End Sub
 
Private Sub Label9_Click()
 
End Sub
 
'
'    Doppelklick auf einen Listbox-Eintrag
'
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
 
   TextBox1.Value = ListBox1.List(Me.ListBox1.ListIndex, 0)
   TextBox2.Value = ListBox1.List(Me.ListBox1.ListIndex, 1)
   TextBox3.Value = ListBox1.List(Me.ListBox1.ListIndex, 2)
   TextBox4.Value = ListBox1.List(Me.ListBox1.ListIndex, 3)
   TextBox5.Value = ListBox1.List(Me.ListBox1.ListIndex, 4)
   TextBox6.Value = ListBox1.List(Me.ListBox1.ListIndex, 5)
   TextBox7.Value = ListBox1.List(Me.ListBox1.ListIndex, 6)
   TextBox8.Value = ListBox1.List(Me.ListBox1.ListIndex, 7)
    
   FundZeile = ListBox1.List(Me.ListBox1.ListIndex, 7)
    
   CommandButton3.Enabled = True  ' den Änder-Button freigeben
   CommandButton4.Enabled = True  ' den Lösch-Button freigeben
 
End Sub
 
'
'   übernehmen
'
Private Sub CommandButton1_Click()
 
Dim lLetzte  As String
Dim iIndex   As Integer
 
   If TextBox1.Value = "" Then
      MsgBox "Sie müssen eine Artikelnummer eingeben - danke.", _
         48, "   Hinweis für " & Application.UserName
      TextBox1.SetFocus
      Exit Sub
   End If
   If TextBox2.Value = "" Then
      MsgBox "Sie müssen einen Artikelnamen eingeben - danke.", _
         48, "   Hinweis für " & Application.UserName
      TextBox2.SetFocus
      Exit Sub
   End If
   If TextBox3.Value = "" Then
      MsgBox "Sie müssen einen Artikelhersteller eingeben - danke.", _
         48, "   Hinweis für " & Application.UserName
      TextBox3.SetFocus
      Exit Sub
   End If
   If TextBox4.Value = "" Then
      MsgBox "Sie müssen ein Regal eingeben - danke.", _
         48, "   Hinweis für " & Application.UserName
      TextBox4.SetFocus
      Exit Sub
   End If
   If TextBox5.Value = "" Then
      MsgBox "Sie müssen ein Segment eingeben - danke.", _
         48, "   Hinweis für " & Application.UserName
      TextBox5.SetFocus
      Exit Sub
   End If
   If TextBox7.Value = "" Then
      MsgBox "Sie müssen eine Ebene eingeben - danke.", _
         48, "   Hinweis für " & Application.UserName
      TextBox7.SetFocus
      Exit Sub
   End If
   If TextBox8.Value = "" Then
      MsgBox "Sie müssen einen Einkaufspreis eingeben - danke.", _
         48, "   Hinweis für " & Application.UserName
      TextBox8.SetFocus
      Exit Sub
   End If
     
'
'   die Daten sind geprüft und können in die Tabelle eingetragen werden
'
 
   Application.ScreenUpdating = False
 
   With Worksheets("Tabelle1")
      .Unprotect Password:="Geheim"
      lLetzte = IIf(.Range("A65536") <> "", 65536, .Range("A65536").End(xlUp).Row) + 1
      If lLetzte < 2 Then lLetzte = 2
      .Range("A" & lLetzte).Value = WorksheetFunction.Proper(TextBox1.Value)
      .Range("B" & lLetzte).Value = WorksheetFunction.Proper(TextBox2.Value)
      .Range("C" & lLetzte).Value = WorksheetFunction.Proper(TextBox3.Value)
      .Range("D" & lLetzte).Value = WorksheetFunction.Proper(TextBox4.Value)
      .Range("E" & lLetzte).Value = WorksheetFunction.Proper(TextBox5.Value)
      .Range("F" & lLetzte).Value = WorksheetFunction.Proper(TextBox6.Value)
      .Range("G" & lLetzte).Value = WorksheetFunction.Proper(TextBox7.Value)
      .Range("H" & lLetzte).Value = WorksheetFunction.Proper(TextBox8.Value)
       
'      Tabelle sortieren
      .Range(.Cells(1, 1), .Cells(lLetzte, 8)).Sort _
            Key1:=.Cells(1, 1), Order1:=xlAscending, _
            Key2:=.Cells(1, 2), Order2:=xlAscending, _
            Key3:=.Cells(1, 4), Order3:=xlAscending, _
            Header:=xlGuess
             
      .Columns("A:H").EntireColumn.AutoFit
             
      Call Zeilen_faerben
       
      With ListBox1
         Call Array_fuellen
         .Clear
         .Column = aTmp
      End With
       
      Label8.Caption = "Anzahl Datensätze:  " & (lLetzte - 1)
            
      .Protect Password:="Geheim"
   End With
    
   For iIndex = 1 To 8
      With Controls("TextBox" & iIndex)
         .Value = ""
      End With
   Next iIndex
    
   Application.ScreenUpdating = True
 
          
End Sub
 
'
'   Eingabeinhalte löschen
'
Private Sub CommandButton5_Click()
 
Dim iIndex  As Integer
 
   For iIndex = 1 To 8
      With Controls("TextBox" & iIndex)
         .Value = ""
      End With
   Next iIndex
    
   CommandButton3.Enabled = False  ' den Änder-Button sperren
   CommandButton4.Enabled = False  ' den Lösch-Button sperren
 
End Sub
 
'
'   suchen
'
Private Sub CommandButton2_Click()
 
Dim WkSh        As Worksheet
Dim lLetzte     As String
Dim myRange     As Range
Dim strAddress  As String
Dim bolAbbruch  As Boolean
 
   CommandButton3.Enabled = False  ' den Änder-Button sperren
   CommandButton4.Enabled = False  ' den Lösch-Button sperren
    
   Set WkSh = Worksheets("Tabelle1")
    
   lLetzte = WkSh.Range("A65536").End(xlUp).Row
   If lLetzte < 2 Then lLetzte = 2
       
   If TextBox1.Value = "" Then
      MsgBox "Es fehlt ein Suchbegriff in der TextBox1 - Abbruch", _
         48, "   Hinweis für " & Application.UserName
      TextBox1.SetFocus
      Exit Sub
    Else
      TextBox1.Value = WorksheetFunction.Proper(TextBox1.Value)
     
   ' nachfolgend werden die TextBox1.Werte gesucht und gefunden.
   ' Mit LookIn:=xlValues wird nach den Zellwerten gesucht.
   ' Mit LookAt:=xlPart muß der Suchbegriff nicht komplett mit
   ' dem Suchergebnis übereinstimmen.
  
      With WkSh
         Set myRange = .Columns(1).Find(What:=UserForm1.TextBox1.Value, _
            LookIn:=xlValues, LookAt:=xlPart, After:=.Cells(Rows.Count, 1))
       
         If Not myRange Is Nothing Then
            strAddress = myRange.Address
            myRange.Activate
            FundZeile = ActiveCell.Row
            GoSub Anzeigen
            Do
               If MsgBox("Weitersuchen?", 36, "   Abfrage") = vbNo Then
                  bolAbbruch = True
                  Exit Sub
                Else
                  Set myRange = .Columns(1).FindNext(myRange)
                  If myRange.Address <> strAddress Then
                     myRange.Activate
                     FundZeile = ActiveCell.Row
                     GoSub Anzeigen
                  End If
               End If
            Loop While Not myRange Is Nothing And myRange.Address <> strAddress
           
            If Not bolAbbruch Then
               MsgBox "Keine weiteren Datensätze gefunden.", _
                   48, "   Information für " & Application.UserName
               FundZeile = 0
             Else
               MsgBox "Keinen übereinstimmenden Datensatz gefunden", _
                  48, "   Information für " & Application.UserName
               FundZeile = 0
            End If
          Else
            MsgBox "Keinen übereinstimmenden Datensatz gefunden", _
               48, "   Information für " & Application.UserName
            FundZeile = 0
            With TextBox2
               .SetFocus
               .SelStart = 0
               .SelLength = Len(.Text)
            End With
         End If
      End With
          
   End If
    
   CommandButton3.Enabled = False  ' den Änder-Button sperren
   CommandButton4.Enabled = False  ' den Lösch-Button sperren
    
   Exit Sub
    
Anzeigen:
 
   If FundZeile = 0 Then Exit Sub
       
   TextBox1.Value = ActiveCell.Offset(0, 0).Value ' Art.-Nummer
   TextBox2.Value = ActiveCell.Offset(0, 1).Value ' Art.-Name
   TextBox3.Value = ActiveCell.Offset(0, 2).Value ' Art.-Hersteller
   TextBox4.Value = ActiveCell.Offset(0, 3).Value ' Regal
   TextBox5.Value = ActiveCell.Offset(0, 4).Value ' Segment
   TextBox6.Value = ActiveCell.Offset(0, 5).Value ' Ebene
   TextBox7.Value = ActiveCell.Offset(0, 6).Value ' Anzahl
   TextBox8.Value = ActiveCell.Offset(0, 7).Value ' Artikelpreis
    
   CommandButton3.Enabled = True  ' den Änder-Button freigeben
   CommandButton4.Enabled = True  ' den Lösch-Button freigeben
     
Return
 
End Sub
 
'
'   ändern
'
Private Sub CommandButton3_Click()
 
Dim lLetzte  As Currency
  
   If TextBox1.Value = "" Then
      MsgBox "Sie müssen eine Artikelnummer eingeben - danke.", _
         48, "   Hinweis für " & Application.UserName
      TextBox1.SetFocus
      Exit Sub
   End If
   If TextBox2.Value = "" Then
      MsgBox "Sie müssen einen Artikelnamen eingeben - danke.", _
         48, "   Hinweis für " & Application.UserName
      TextBox2.SetFocus
      Exit Sub
   End If
   If TextBox3.Value = "" Then
      MsgBox "Sie müssen einen Artikelhersteller eingeben - danke.", _
         48, "   Hinweis für " & Application.UserName
      TextBox3.SetFocus
      Exit Sub
   End If
   If TextBox4.Value = "" Then
      MsgBox "Sie müssen ein Regal eingeben - danke.", _
         48, "   Hinweis für " & Application.UserName
      TextBox4.SetFocus
      Exit Sub
   End If
   If TextBox5.Value = "" Then
      MsgBox "Sie müssen ein Segment eingeben - danke.", _
         48, "   Hinweis für " & Application.UserName
      TextBox5.SetFocus
      Exit Sub
   End If
   If TextBox6.Value = "" Then
      MsgBox "Sie müssen eine Ebene eingeben - danke.", _
         48, "   Hinweis für " & Application.UserName
      TextBox6.SetFocus
      Exit Sub
   End If
   If TextBox7.Value = "" Then
      MsgBox "Sie müssen eine Anzahl eingeben - danke.", _
         48, "   Hinweis für " & Application.UserName
      TextBox7.SetFocus
      Exit Sub
   End If
   If TextBox8.Value = "" Then
      MsgBox "Sie müssen einen Artikelpreis eingeben - danke.", _
         48, "   Hinweis für " & Application.UserName
      TextBox8.SetFocus
      Exit Sub
   End If
'
'   die Daten sind geprüft und können in die Tabelle eingetragen werden
'
   Application.ScreenUpdating = False
 
   With Worksheets("Tabelle1")
      .Unprotect Password:="Geheim"
      .Range("A" & FundZeile).Value = WorksheetFunction.Proper(TextBox1.Value)
      .Range("B" & FundZeile).Value = WorksheetFunction.Proper(TextBox2.Value)
      .Range("C" & FundZeile).Value = WorksheetFunction.Proper(TextBox3.Value)
      .Range("D" & FundZeile).Value = WorksheetFunction.Proper(TextBox4.Value)
      .Range("E" & FundZeile).Value = WorksheetFunction.Proper(TextBox5.Value)
      .Range("F" & FundZeile).Value = WorksheetFunction.Proper(TextBox6.Value)
      .Range("G" & FundZeile).Value = WorksheetFunction.Proper(TextBox7.Value)
      .Range("H" & FundZeile).Value = WorksheetFunction.Proper(TextBox8.Value)
       
      lLetzte = IIf(.Range("A65536") <> "", 65536, .Range("A65536").End(xlUp).Row) + 1
      If lLetzte < 2 Then lLetzte = 2
      Label8.Caption = "Anzahl Datensätze:  " & (lLetzte - 1)
       
'      Tabelle sortieren
      .Range(.Cells(2, 1), .Cells(lLetzte, 8)).Sort _
            Key1:=.Cells(1, 1), Order1:=xlAscending, _
            Key2:=.Cells(1, 2), Order2:=xlAscending, _
            Key3:=.Cells(1, 4), Order3:=xlAscending, _
            Header:=xlGuess
             
      .Columns("A:H").EntireColumn.AutoFit
             
      Call Zeilen_faerben
       
      With ListBox1
         Call Array_fuellen
         .Clear
         .Column = aTmp
      End With
             
      .Protect Password:="Geheim"
   End With
    
   Application.ScreenUpdating = True
 
   CommandButton3.Enabled = False  ' den Änder-Button sperren
   CommandButton4.Enabled = False  ' den Lösch-Button sperren
 
End Sub
 
'
'   löschen
'
Private Sub CommandButton4_Click()
 
   With Worksheets("Tabelle1")
      .Unprotect Password:="Geheim"
      If FundZeile <> 0 Then
         If MsgBox("Wollen Sie den/die  """ & TextBox2.Value & " " & _
            TextBox1.Value & """  wirklich löschen.", _
            vbYesNo + vbQuestion, "    Löschabfrage, nur zur Sicherheit.") = vbYes Then
            .Rows(FundZeile).Delete Shift:=xlUp
            .Columns("A:H").EntireColumn.AutoFit
            Call Zeilen_faerben
            ListBox1.RemoveItem ListBox1.ListIndex
            ListBox1.ListIndex = -1
            Unload UserForm1
         End If
      End If
      .Protect Password:="Geheim"
   End With
 
   CommandButton3.Enabled = False  ' den Änder-Button sperren
   CommandButton4.Enabled = False  ' den Lösch-Button sperren
 
End Sub
 
Private Sub TextBox3_Change()
 
End Sub
 
'
'   das UserForm(ular) intialisieren, die ListBox 'geraderücken'
'
Private Sub UserForm_Activate()
 
Dim lLetzte  As String
 
   Call Array_fuellen
    
   Me.Caption = "Lagerverwaltung Dallmayr"
   Me.Width = 490
   Me.Height = 420
    
   With ListBox1        ' betrifft die ListBox1
      .Height = 82      ' die Höhe festlegen
      .Left = 12        ' den linken Randabstand festlegen
      .Top = 12         ' den oberen Randabstand festlegen
      .Width = 460      ' die Breite festlegen
      .Font.Size = 10   ' die Schriftgröße festlegen
      .ForeColor = RGB(0, 0, 255) ' Schriftfarbe immer mit RGB
      .ColumnCount = 8  ' die Anzahl der Spalten festlegen
                        ' die Breite der Spalten festlegen
      .ColumnWidths = _
      ("2,5 cm;4,5 cm;2 cm;1 cm;1 cm;1 cm;1 cm;2 cm")
      .Clear            ' die ListBox leeren
      If WorksheetFunction.CountA(aTmp()) > 0 Then
         .Column = aTmp
      End If
   End With
    
   CommandButton3.Enabled = False  ' den Änder-Button sperren
   CommandButton4.Enabled = False  ' den Lösch-Button sperren
    
   With Worksheets("Tabelle1")
      lLetzte = IIf(IsEmpty(.Cells(Rows.Count, 1)), _
         .Cells(Rows.Count, 1).End(xlUp).Row, Rows.Count)
      If lLetzte < 2 Then lLetzte = 2
      Label8.Caption = "Anzahl Datensätze:  " & (lLetzte - 1)
   End With
 
End Sub

 


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
15.04.2015 15:42:50 Sven
NotSolved
15.04.2015 15:43:23 Gast82889
NotSolved
Rot Lagerverwaltung über Userform
15.04.2015 17:26:14 Sven
NotSolved
15.04.2015 17:49:39 Sven
NotSolved