Hi,
I'm trying to open multiple xlsx files and updated based on a list from another sheet, with VBA, but I created VBA only for one line from communication matrix and i need it for all lines
I'm trying to open multiple xlsx files and updated based on a list from another sheet, with VBA, but I created VBA only for one line from communication matrix and i need it for all lines
VBA Code:
Sub Update_regionali()
Dim i As Integer
Dim last_row As Integer
last_row = Application.WorksheetFunction.CountA(Worksheets("Distributie Mail").Range("H:H"))
For i = 2 To last_row
' Update
If Worksheets("Distributie Mail").Range("I2") = "OK" Then
Workbooks.Open ("Z:\Q1\Planificari\Planificari Regionali\Planificare site-uri Alexandru Bria.xlsx")
Sheets("Planificare").Select
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
Windows("Planificare Regionali.xlsb").Activate
Sheets("Planificare").Select
If Not ActiveSheet.AutoFilterMode Then
ActiveSheet.Range("A1:Z1").AutoFilter
End If
ActiveSheet.Range("$A$1:$Z$21").AutoFilter Field:=29, Criteria1:= _
"Alexandru Bria"
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("Planificare site-uri Alexandru Bria.xlsx").Activate
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.Save
Columns("A:Z").EntireColumn.AutoFit
ActiveWorkbook.Save
ActiveWindow.Close
Windows("Planificare Regionali.xlsb").Activate
End If
Windows("Planificare Regionali.xlsb").Activate
Sheets("Planificare").Select
' If ActiveSheet.AutoFilterMode = False Then
' ActiveSheet.ShowAllData
' End If
Range("A1").Select
Sheets("Distributie Mail").Select
Range("A1").Select
Exit For
Next i
End Sub
my communication matrix
[ATTACH type="full"]54577[/ATTACH]