Moderatori: Anthony47, Flash30005
Sub mormadiss()
Dim C As Integer, I As Integer
If ActiveWorkbook.Name = ThisWorkbook.Name Then
MsgBox ("Selezionare il File /Foglio da normalizzare e poi lanciare la macro")
Exit Sub
End If
For C = 1 To Cells(1, Columns.Count).End(xlToLeft).Column
If IsError(Application.Match(Cells(1, C), _
ThisWorkbook.Sheets("Modello").Range("1:1"), 0)) Then
MsgBox ("Valore " & Cells(1, C).Value & " in " & Cells(1, C).Address & " non in MODELLO")
Exit Sub
End If
Next C
I = 0
For C = 1 To Cells(1, Columns.Count).End(xlToLeft).Column
If Cells(1, C + I) <> ThisWorkbook.Sheets("Modello").Cells(1, C + I) Then
Cells(1, C + I).EntireColumn.Insert Shift:=xlToRight
ThisWorkbook.Sheets("Modello").Cells(1, C + I).EntireColumn.Copy _
Destination:=Cells(1, C + I)
I = I + 1: C = C - 1
End If
Next C
End Sub
ok, l'unico problema è però che l'ordine in cui compaiono le colonne può essere differente tra i vari file...e credo che la macro non tenga in considerazione questa cosa, o sbaglio?
Sub mormadiss2()
Dim C As Integer, I As Integer
CWb = ActiveWorkbook.FullName
MsgBox (CWb)
If ActiveWorkbook.Name = ThisWorkbook.Name Then
MsgBox ("Selezionare il File /Foglio da normalizzare e poi lanciare la macro")
Exit Sub
End If
For C = 1 To Cells(1, Columns.Count).End(xlToLeft).Column
If IsError(Application.Match(Cells(1, C), _
ThisWorkbook.Sheets("Modello").Range("1:1"), 0)) Then
MsgBox ("Valore " & Cells(1, C).Value & " in " & Cells(1, C).Address & " non in MODELLO")
Exit Sub
End If
Next C
For C = 1 To Cells(1, Columns.Count).End(xlToLeft).Column
CDest = Application.Match(Cells(1, C), ThisWorkbook.Sheets("Modello").Range("1:1"), 0)
Cells(1, C).EntireColumn.Copy _
Destination:=ThisWorkbook.Sheets("Modello").Cells(1, CDest)
Next C
ThisWorkbook.Activate
NWbName = Replace(CWb, ".xls", "_NORM.xls") '<< *** vedi testo
ActiveWorkbook.SaveAs Filename:=NWbName, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub
Workbooks.Open Filename:= _
"C:\Documents and Settings\Utente\Documenti\Modello.xls" _
, Editable:=True
Torna a Applicazioni Office Windows
Inserire add.in nella barra di avvio veloce in excel 2003 Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 4 |
Excel: problema con date se devo unirle a testi Autore: valle1975 |
Forum: Applicazioni Office Windows Risposte: 5 |
Visitano il forum: Nessuno e 45 ospiti