AW: Zellen aneinanderfügen, Leerzellen ignorieren
01.01.2006 18:54:08
Reinhard
Hi Tobias,
du kannst entweder in Tabelle3 die zahlen eintragen oder in Tabelle2. Nachstehender Code notiert automatisch alles mit.
https://www.herber.de/bbs/user/29611.xls
Gruß
Reinhard
ps:Das Forum lebt auch von Rückmeldungen.
Tabelle2 hat einen Spinbutton und ein Textfeld, sowie die 5 Zahlenzellen und die Zelle die die Anzahl anzeigt.
Der Code von Tabelle2:
Option Explicit
Private Sub SpinButton1_Change()
Dim ws2
Application.ScreenUpdating = False
Application.EnableEvents = False
Set ws2 = Worksheets("Tabelle2")
With Worksheets("Tabelle3")
TextBox1 = .Range("A" & SpinButton1)
ws2.Range("g4") = Application.WorksheetFunction.VLookup(.Range("A" & SpinButton1), .Range("A2:F122"), 2, 0)
ws2.Range("g5") = Application.WorksheetFunction.VLookup(.Range("A" & SpinButton1), .Range("A2:F122"), 3, 0)
ws2.Range("g6") = Application.WorksheetFunction.VLookup(.Range("A" & SpinButton1), .Range("A2:F122"), 4, 0)
ws2.Range("g7") = Application.WorksheetFunction.VLookup(.Range("A" & SpinButton1), .Range("A2:F122"), 5, 0)
ws2.Range("g8") = Application.WorksheetFunction.VLookup(.Range("A" & SpinButton1), .Range("A2:F122"), 6, 0)
ws2.Range("g10") = Application.WorksheetFunction.Count(Range("G4:G8"))
End With
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("g4:g8")) Is Nothing Then
With Worksheets("Tabelle3")
.Cells(SpinButton1, Target.Row - 2) = Target
End With
Worksheets("Tabelle2").Range("g10") = Application.WorksheetFunction.Count(Range("G4:G8"))
End If
End Sub