Need some help ^^
28.08.2007 09:24:16
HalMar
Hi,
Hab hier ein Problem:
Private Sub CommandButton2_Click()
Dim Checkcount As Long
Dim myRange
Dim myUnion
Dim Zahl1 As Long
Dim newRange As Range
Dim Zahl2 As Long
Zahl1 = Range("C1")
Zahl2 = Range("E1")
Dim Colcount
Colcount = ActiveSheet.UsedRange.Columns.Count
For Checkcount = 1 To Colcount
If Left(ActiveSheet.OLEObjects(Checkcount).Name, 8) = "CheckBox" Then
If ActiveSheet.OLEObjects(Checkcount).Object.Value = True Then
myRange = Range(Cells(1, Zahl1), Cells(1, Zahl2)).Offset(Checkcount, 0)
myUnion = Union(myUnion, myRange, Range("A5").Offset(Checkcount, 0))
End If
End If
Next Checkcount
myUnion = Union(myUnion, Range("A5"), Range(Cells(1, Zahl1), Cells(1, Zahl2)))
ActiveSheet.Range(myUnion).Copy
ActiveWorkbook.Sheets.Add
ActiveSheet.Paste
Application.CutCopyMode = False
Charts.Add
End Sub
Ich hab das jetzt mal mit Offset, Cells und Union versucht, allerdings schreibt er mir nichts auf myRange und myUnion. Er läuft dann (je nachdem welche Checkboxen aktiviert sind) ein paar mal ab, geht dann über myRange(leer), auf myUnion(ebenfalls leer) und gibt den Fehler (Objekt erforderlich). Was genau habe ich da alles falsch gemacht?
Mit hoffnung auf eine schnelle Antwort,
Lg, Mario