AW: wert aus bestimmten bereich kopieren und einfügen
07.10.2017 20:11:02
Kay
Hallo fkw48,
also das mit den Spalten habe ich verstanden und es funktioniert auch schon mal, wie ich es gerne hätte.
Leider bekomme ich es nicht mit hin, das wirklich die Zeilen beschrieben werden, die ich in den Comboboxen auswähle. Ich verstehe leider auch nicht, welchen If Befehl ich raus lassen soll. Hab jetzt alles mal versucht, aber ich bekomme immer eine Fehlermeldung.
Ich habe den Code jetzt mal so angepasst, rein zum testen, allerdings wird immer nur ein Zeile beschrieben und nicht alle leeren Zeilen im z.B. Bereich 15-25.
Könntest du mir vielleicht nochmal hierbei verständlicher helfen?
Option Explicit
Dim rngA As Range
Private Sub CommandButton1_Click()
Dim rngC As Range, fA As String
Application.ScreenUpdating = False
With Columns("D")
Set rngC = .Find(rngA.Value, LookIn:=xlValues)
If Not rngC Is Nothing Then
fA = rngC.Address
Do
With rngC.Offset(1)
If rngC.Row >= UserForm1.ComboBox1.Value Then
If rngC.Row fA
End If
End With
Unload UserForm1
Application.ScreenUpdating = True
End Sub
Private Sub CommandButton2_Click()
Unload UserForm1
End Sub
Private Sub CommandButton3_Click()
Dim rngC As Range, fA As String
Application.ScreenUpdating = False
With Columns("D")
Set rngC = .Find(rngA.Value, LookIn:=xlValues)
If Not rngC Is Nothing Then
fA = rngC.Address
Do
With rngC.Offset(1)
If .Value "" Then .Value = ""
If .Offset(, 1).Value "" Then .Offset(, 1).Value = ""
End With
Set rngC = .FindNext(rngC)
Loop While Not rngC Is Nothing And rngC.Address fA
End If
End With
Unload UserForm1
Application.ScreenUpdating = True
End Sub
Private Sub UserForm_Initialize()
Dim cnt As Long
IsIt
If UserForm1.Frame1.Visible = True Then
FillCombos
UserForm1.ComboBox1.Value = rngA.Row
With UserForm1.ComboBox2
cnt = .ListCount
If rngA.Row > 1 Then
.Value = UserForm1.ComboBox2.List(cnt - 1)
Else
.Value = UserForm1.ComboBox2.List(cnt - 2)
End If
End With
End If
End Sub
Private Sub FillCombos()
Dim rngC As Range, fA As String
Application.ScreenUpdating = False
With Columns("D")
Set rngC = .Find(rngA.Value, LookIn:=xlValues)
If Not rngC Is Nothing Then
fA = rngC.Address
Do
UserForm1.ComboBox1.AddItem rngC.Row
UserForm1.ComboBox2.AddItem rngC.Row
Set rngC = .FindNext(rngC)
Loop While Not rngC Is Nothing And rngC.Address fA
End If
End With
Application.ScreenUpdating = True
End Sub
Private Sub IsIt()
UserForm1.Frame1.Visible = False
Set rngA = ActiveCell
Set rngA = Intersect(rngA, Columns("D"))
If Not rngA Is Nothing Then
If ActiveCell.Value "" Then
UserForm1.Label1.Caption = "Artikel in Spalte A = " & rngA.Value
UserForm1.Frame1.Visible = True
Else
UserForm1.Label1.Caption = "kein Artikel in Spalte A selektiert!"
End If
End If
End Sub