BUongiorno a tutti!
Ringrazio in anticipo chiunque mi voglia aiutare a risolvere questo problema!
Devo modificare tantissimi file cambiando il formato delle celle da "generale" a "formato numerico.
Ho registrato una macro che lo faccia dopo aver aperto il file e fino a qui tutto bene, ma dato il numero eccessivo di file vorrei sapere se esiste un modo per processare tutti i file contenuti in una cartella con la stessa macro.
quella che ho registrato io è questa:
Sub formatonum()
'
' formatonum Macro
'
' Scelta rapida da tastiera: CTRL+MAIUSC+F
'
Selection.CurrentRegion.Select
Selection.NumberFormat = "0.00"
ActiveCell.Offset(0, 4).Range("A1").Select
ActiveWorkbook.Save
End Sub
Su internet ne ho trovata un'altra che dovrebbe automatizzare il processo ma non sono riuscita a farla funzionare.
Sub ExecuteApplyMacroToAllFiles()
'Change the path to the main folder
Call ApplyMacroToAllFiles("C:\test folder")
End Sub
Sub ApplyMacroToAllFiles(ByVal MyPath As String)
Dim FileSys As Object
Dim objFolder As Object
Dim objSubFolder As Object
Dim objFile As Object
Dim wkbOpen As Workbook
Set FileSys = CreateObject("Scripting.FileSystemObject")
Set objFolder = FileSys.GetFolder(MyPath)
Application.ScreenUpdating = False
For Each objSubFolder In objFolder.SubFolders
For Each objFile In objSubFolder.Files
Set wkbOpen = Workbooks.Open(filename:=objFile)
'Change the name of your macro
Call MyMacro
wkbOpen.Close savechanges:=True
Next
Call ApplyMacroToAllFiles(objSubFolder.Path)
Next
Application.ScreenUpdating = True
End Sub
Allego dei file di sample
[Modificato da RitaKant 23/03/2017 08:01]