Moderatori: Anthony47, Flash30005
golberg ha scritto:e far selezionare automaticamente dalla macro quel file.
Public perc As String
Sub ElencoFileXls()
perc = "C:\temp\" '<<<< cambia percorso secondo la tua esigenza
Worksheets("Foglio1").Select
Range("A1").Select
With ActiveCell
Worksheets("Foglio1").Range(.Cells(1, 2), .End(xlDown)).ClearContents
End With
ElencoFile Direct:=perc, Estens:="*.xls", Inicell:=ActiveCell '<<<< Puoi mettere Estens:="Pippo*.xls"
Columns("A:B").Select
Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A1").Select
End Sub
Sub ElencoFile(Direct As String, Estens As String, Inicell As Range)
Dim i As Integer, f As String
ChDir Direct
Set oFs = CreateObject("Scripting.FileSystemObject")
f = Dir(Estens)
If f = "" Then Exit Sub
While f <> ""
DataF = FileDateTime(f)
i = i + 1
Inicell(i) = f
f = Dir
Wend
End Sub
LFor = "pippo" '<< La "base" del nome file da attivare
For Each OWb In Workbooks
If UCase(Left(OWb.Name, Len(LFor))) = UCase(LFor) Then OWb.Activate: Exit For
Next OWb
Dim mycell As String
mDir = ActiveWorkbook.Path
fileToOpen = Application.GetOpenFilename("XLS Files (*.xls), *.xls")
mycell = fileToOpen
Può essere utile il fatto che ho definito il file che apro con:Si può fare riferimento a questa definizione per richiamare e chiudere il file aperto?
- Codice: Seleziona tutto
Dim mycell As String
mDir = ActiveWorkbook.Path
fileToOpen = Application.GetOpenFilename("XLS Files (*.xls), *.xls")
mycell = fileToOpen
f1Name = Mid(fileToOpen, InStrRev(fileToOpen, "\") + 1, 999)
Workbooks(f1Name).Close SaveChanges:=False
Torna a Applicazioni Office Windows
Macro modifica date scelta periodo Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 11 |
Supporto per sviluppo macro VBA Ordinare per data Autore: Carletto Ribolla |
Forum: Applicazioni Office Windows Risposte: 3 |
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 16 ospiti