Hy Wieso fügt er mir hier immer nur die Zeilen aus dem ersten Auswahl?
ComboBox2 soll eigentlich die Zeilen in Zeile A6:V7 einfügen aus dem Zweiten Auswahl er fügt jedoch in Zeile A4:V6 und A6:V7
gleiche werte obwohl in beiden Ausgewählten Dateien verschiedene Werte stehen!!!
Private
Const
ROOT_FOLDER
As
String
= "C:\Users\asus\Desktop\data\excel\"
Private
Sub
CommandButton1_Click()
Dim
i
As
Long
Dim
blatt
As
Long
Dim
objWorbook
As
Workbook
With
Application
.Calculation = xlCalculationManual
.EnableEvents =
False
.ScreenUpdating =
False
End
With
blatt = 0
For
i = 1
To
6
If
Me
.Controls(
"OptionButton"
& i).Value =
True
Then
blatt = i
Next
i
If
blatt = 0
Then
End
Label1.Caption =
"Bitte warten, Berechnung läuft..."
UserForm1.Repaint
If
ComboBox1.ListIndex > -1
Then
Set
objWorbook = Workbooks.Open(Filename:= _
ROOT_FOLDER & ComboBox1.Text, UpdateLinks:=0,
ReadOnly
:=
True
)
Call
objWorbook.Worksheets(blatt).Range(
"A201:V202"
).Copy
ThisWorkbook.Worksheets(1).Cells(4 + i, 1).PasteSpecial xlValues, Operation:=xlNone, SkipBlanks _
:=
False
, Transpose:=
False
Call
objWorbook.Close(SaveChanges:=
False
)
Set
objWorbook =
Nothing
Range(
"A12345"
).Copy
Application.CutCopyMode =
False
End
If
If
ComboBox2.ListIndex > -1
Then
Set
objWorbook = Workbooks.Open(Filename:= _
ROOT_FOLDER & ComboBox1.Text, UpdateLinks:=0,
ReadOnly
:=
True
)
Call
objWorbook.Worksheets(blatt).Range(
"A201:V202"
).Copy
ThisWorkbook.Worksheets(1).Cells(6 + i, 1).PasteSpecial xlValues, Operation:=xlNone, SkipBlanks _
:=
False
, Transpose:=
False
Call
objWorbook.Close(SaveChanges:=
False
)
Set
objWorbook =
Nothing
Range(
"A12345"
).Copy
Application.CutCopyMode =
False
End
If
End
Sub