Ik heb een macro gemaakt om gegevens over te zetten van 1 bestand naar een ander.
Maar helaas veranderd de bronkolom elke week.
Vb deze week is dit 44 en 51 en volgende week is dit 45 en 52.
Kan ik dit in de macro verwerken?
Maar helaas veranderd de bronkolom elke week.
Vb deze week is dit 44 en 51 en volgende week is dit 45 en 52.
Kan ik dit in de macro verwerken?
Code:
Sub PRODUCTGROEPEN2014()
Dim ActWb As String
Dim IP As String
Dim BronRij As Integer
Dim BronKolom As Integer
Dim SchrijfRij As Integer
Dim SchrijfKolom As Integer
Dim Teller As Integer
ActWb = ActiveWorkbook.Name
Select Case Workbooks.Count
Case 1
MsgBox "Er is geen ander werkblad open", vbInformation, "Geen ander werkblad open"
Exit Sub
Case Else
For Teller = 1 To Workbooks.Count
If Workbooks(Teller).Name <> ActWb Then
BronKolom = 44
For SchrijfKolom = 9 To 9
SchrijfRij = 1
While Workbooks(ActWb).Worksheets("Productgroepen").Cells(SchrijfRij, SchrijfKolom) <> ""
SchrijfRij = SchrijfRij + 1
Wend
For BronRij = 19 To 29
Workbooks(Teller).Activate
If Worksheets("ProductSAM").Cells(BronRij, 2) <> "" Then
Worksheets("ProductSAM").Cells(BronRij, BronKolom).Select
Selection.Copy
Workbooks(ActWb).Activate
Worksheets("Productgroepen").Cells(SchrijfRij, SchrijfKolom).Select
Selection.PasteSpecial Paste:=xlPasteValues
SchrijfRij = SchrijfRij + 1
End If
Next
BronKolom = BronKolom + 1
Next
BronKolom = 51
For SchrijfKolom = 3 To 3
SchrijfRij = 1
While Workbooks(ActWb).Worksheets("Productgroepen").Cells(SchrijfRij, SchrijfKolom) <> ""
SchrijfRij = SchrijfRij + 1
Wend
For BronRij = 19 To 29
Workbooks(Teller).Activate
If Worksheets("ProductSAM").Cells(BronRij, 2) <> "" Then
Worksheets("ProductSAM").Cells(BronRij, BronKolom).Select
Selection.Copy
Workbooks(ActWb).Activate
Worksheets("Productgroepen").Cells(SchrijfRij, SchrijfKolom).Select
Selection.PasteSpecial Paste:=xlPasteValues
SchrijfRij = SchrijfRij + 1
End If
Next
BronKolom = BronKolom + 1
Next
End If
Next
End Select
End Sub