Moderatori: Anthony47, Flash30005
Option Explicit
Option Compare Text
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim a As Long, i As Long, j As Long, nr As Long, ur As Long
Dim cc As String, qq As String, pp As String
Dim p, f, s, cod, qnt, prz
If Not Intersect(Target, Range("A1")) Is Nothing Then
ur = Sheets(1).Cells(Rows.Count, "B").End(xlUp).Row: If ur < 3 Then ur = 3
Range("f3:h" & ur).ClearContents
a = 3
nr = Sheets(2).Cells(Rows.Count, "B").End(xlUp).Row
If nr < 3 Then Exit Sub
For i = 2 To nr
'definisce termini per la funzione di ricerca
p = Sheets(2).Cells(2, 1).Text 'percorso (path)
f = Sheets(2).Cells(i, 2).Text 'nome file
s = "Foglio1"
For j = 35 To 49
cc = "A" & j: cod = GetValue(p, f, s, cc)
If cod = 0 Then Exit For
qq = "F" & j: qnt = GetValue(p, f, s, qq)
pp = "H" & j: prz = GetValue(p, f, s, pp)
With Sheets(1)
Range("F" & a) = cod 'da aggiustare con "B"
Range("G" & a) = qnt 'da aggiustare con "C"
Range("H" & a) = prz 'da aggiustare con "D"
a = a + 1
End With
Next j
Next
End If
End Sub
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim fs, f, fn, f1, s, sf
Dim ur As Long, a As Long
If Not Intersect(Target, Cells(1, 4)) Is Nothing Then
ur = Cells(Rows.Count, "B").End(xlUp).Row: If ur < 2 Then ur = 2
Range("B2:B" & ur).ClearContents
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(Cells(2, 1).Value)
Set fn = f.Files
a = 1
For Each f1 In fn
a = a + 1
Cells(a, 2) = f1.Name
Next
End If
End Sub
Option Explicit
Public Function GetValue(path, file, sheet, ref)
Dim arg As String
If Right(path, 1) <> "\" Then path = path & "\"
If Dir(path & file) = "" Then
GetValue = "File non trovato"
Exit Function
End If
arg = "'" & path & "[" & file & "]" & sheet & "'!" & _
Range(ref).Range("A1").Address(, , xlR1C1)
GetValue = ExecuteExcel4Macro(arg)
End Function
For j = 35 To 49
cc = "A" & j: cod = GetValue(p, f, s, cc)
If cod = 0 Then Exit For '<<<<< questa riga da correggere
qq = "F" & j: qnt = GetValue(p, f, s, qq)
pp = "H" & j: prz = GetValue(p, f, s, pp)
With Sheets(1)
Range("F" & a) = cod 'da aggiustare con "B"
Range("G" & a) = qnt 'da aggiustare con "C"
Range("H" & a) = prz 'da aggiustare con "D"
a = a + 1
End With
Next j '<<<<<< questa riga da correggere
Torna a Applicazioni Office Windows
Macro modifica date scelta periodo Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 11 |
Inserire dati filtrati da 2 file ad un terzo file Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 14 |
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 |
Visitano il forum: Anthony47 e 22 ospiti