
Option Explicit
Sub read_closed_1()
Dim app As New Excel.Application, wbk As Excel.Workbook, file_name As String
'apre il file ma non lo rende visibile
file_name = "c:users5314495desktoppippo.xlsx"
Set wbk = app.Workbooks.Add(file_name)
'----------------------------------------------------------------
' Le operazioni col file cominciano qui
MsgBox "In cella A1 c'è questo: '" & wbk.Worksheets("foglio1").Range("A1") & "'"
' e finiscono qui
wbk.Close SaveChanges:=False
app.Quit
Set app = Nothing
'-----------------------------------------------------------------
End Sub
Sub read_closed_2()
Dim sPath As String, sFile As String, s As String
'accede a celle del file chiuso, senza aprirlo
sPath = "c:users5314495desktop"
sFile = "pippo.xlsx"
s = "'" & sPath & "[" & sFile & "]Foglio1'!R1C1"
MsgBox "In cella A1 c'è questo: '" & ExecuteExcel4Macro(s) & "'", vbInformation, sFile
End Sub |
Option Explicit
Sub Cerca()
Application.ScreenUpdating = False
Dim Cln As Byte
Dim Riga As Long
Dim Form As String
Riga = ActiveCell.Row
For Cln = 2 To 30
Select Case Cln
Case 2
Form = "=SE.ERRORE(CERCA.VERT($C" & Riga & ";'C:ProveIrene[DATI.xlsm.xlsx]Disegni'!$A:$N;" & 3 & ";0);" & Chr(34) & Chr(34) & ")"
Cells(Riga, Cln).FormulaLocal = Form
Case 4
Form = "=SE.ERRORE(CERCA.VERT($C" & Riga & ";'C:ProveIrene[DATI.xlsm.xlsx]Disegni'!$A:$N;" & 14 & ";0);" & Chr(34) & Chr(34) & ")"
Cells(Riga, Cln).FormulaLocal = Form
Case 7
Form = "=SE.ERRORE(CERCA.VERT($C" & Riga & ";'C:ProveIrene[DATI.xlsm.xlsx]Disegni'!$A:$N;" & 9 & ";0);" & Chr(34) & Chr(34) & ")"
Cells(Riga, Cln).FormulaLocal = Form
Case 8
Form = "=SE.ERRORE(CERCA.VERT($C" & Riga & ";'C:ProveIrene[DATI.xlsm.xlsx]Disegni'!$A:$N;" & 8 & ";0);" & Chr(34) & Chr(34) & ")"
Cells(Riga, Cln).FormulaLocal = Form
Case 10
Form = "=$C" & Riga
Cells(Riga, Cln).FormulaLocal = Form
Case 20
Form = "=SE.ERRORE(CERCA.VERT($C" & Riga & ";'C:ProveIrene[DATI.xlsm.xlsx]Disegni'!$A:$N;" & 5 & ";0);" & Chr(34) & Chr(34) & ")"
Cells(Riga, Cln).FormulaLocal = Form
Case 27
Form = "=SE.ERRORE(CERCA.VERT($C" & Riga & ";'C:ProveIrene[DATI.xlsm.xlsx]Disegni'!$A:$N;" & 4 & ";0);" & Chr(34) & Chr(34) & ")"
Cells(Riga, Cln).FormulaLocal = Form
Case 30
Form = "=SE.ERRORE(SE(STRINGA.ESTRAI(CERCA.VERT($C" & Riga & ";'C:ProveIrene[DATI.xlsm.xlsx]Disegni'!$A:$N;7;0);1;3)=" & Chr(34) & "EXW" & Chr(34) & ";" & Chr(34) & "Cliente" & Chr(34) & ";SE(CERCA.VERT($C" & Riga & ";'C:ProveIrene[DATI.xlsm.xlsx]Disegni'!$A:$N;7;0)=" & Chr(34) & Chr(34) & ";" & Chr(34) & "nn" & Chr(34) & ";" & Chr(34) & "morandini" & Chr(34) & " ));" & Chr(34) & Chr(34) & ")"
Cells(Riga, Cln).FormulaLocal = Form
End Select
Cells(Riga, Cln).Copy
Cells(Riga, Cln).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Next Cln
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
|
Sub read_closed_2()
Dim sPath As String, sFile As String, s As String
'accede a celle del file chiuso, senza aprirlo
sPath = "f:forgeirene"
sFile = "Dati.xlsm.xlsx"
s = "'" & sPath & "[" & sFile & "]Disegni'!R2C3"
MsgBox "In cella A1 c'è questo: '" & ExecuteExcel4Macro(s) & "'", vbInformation, sDati.xlsm.xlsx
End Sub
|
MsgBox "In cella A1 c'è questo: '" & ExecuteExcel4Macro(s) & "'", vbInformation, sDati.xlsm.xlsx
Option Explicit
Sub Cerca()
Application.ScreenUpdating = False
Dim Cln As Byte
Dim Riga As Long
Dim Form As String
' Const Path As String = "'C:ProveIrene[DATI.xlsm]" ' Utilizzata per i miei Test
Const Path As String = "'f:forgeirene[DATI.xlsm]" ' Queta dovrebbe essere la Tua Path
Riga = ActiveCell.Row
For Cln = 2 To 30
Select Case Cln
Case 2
Form = "=SE.ERRORE(CERCA.VERT($C" & Riga & ";" & Path & "Disegni'!$A:$N;" & 3 & ";0);" & Chr(34) & Chr(34) & ")"
Cells(Riga, Cln).FormulaLocal = Form
Case 4
Form = "=SE.ERRORE(CERCA.VERT($C" & Riga & ";" & Path & "Disegni'!$A:$N;" & 14 & ";0);" & Chr(34) & Chr(34) & ")"
Cells(Riga, Cln).FormulaLocal = Form
Case 7
Form = "=SE.ERRORE(CERCA.VERT($C" & Riga & ";" & Path & "Disegni'!$A:$N;" & 9 & ";0);" & Chr(34) & Chr(34) & ")"
Cells(Riga, Cln).FormulaLocal = Form
Case 8
Form = "=SE.ERRORE(CERCA.VERT($C" & Riga & ";" & Path & "Disegni'!$A:$N;" & 8 & ";0);" & Chr(34) & Chr(34) & ")"
Cells(Riga, Cln).FormulaLocal = Form
Case 10
Form = "=$C" & Riga
Cells(Riga, Cln).FormulaLocal = Form
Case 20
Form = "=SE.ERRORE(CERCA.VERT($C" & Riga & ";" & Path & "Disegni'!$A:$N;" & 5 & ";0);" & Chr(34) & Chr(34) & ")"
Cells(Riga, Cln).FormulaLocal = Form
Case 27
Form = "=SE.ERRORE(CERCA.VERT($C" & Riga & ";" & Path & "Disegni'!$A:$N;" & 4 & ";0);" & Chr(34) & Chr(34) & ")"
Cells(Riga, Cln).FormulaLocal = Form
Case 30
Form = "=SE.ERRORE(SE(STRINGA.ESTRAI(CERCA.VERT($C" & Riga & ";" & Path & "Disegni'!$A:$N;7;0);1;3)=" & Chr(34) & "EXW" & Chr(34) & ";" & Chr(34) & "Cliente" & Chr(34) & ";SE(CERCA.VERT($C" & Riga & ";" & Path & "Disegni'!$A:$N;7;0)=" _
& Chr(34) & Chr(34) & ";" & Chr(34) & "nn" & Chr(34) & ";" & Chr(34) & "morandini" & Chr(34) & " ));" & Chr(34) & Chr(34) & ")"
Cells(Riga, Cln).FormulaLocal = Form
End Select
Cells(Riga, Cln).Copy
Cells(Riga, Cln).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Next Cln
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub |
Private Sub WORKSHEET_change(ByVal TARGET As Range)
Dim I As Integer
Dim s As Date
Dim D As Date
Dim r As Integer
Dim gg As String
gg = ActiveSheet.Name
Select Case UCase(Worksheets(gg).Cells(3, 1))
Case ("Lunedì")
r = 0
Case ("Martedì")
r = 1
Case ("Mercoledì")
r = 2
Case ("Giovedì")
r = 3
Case ("Venerdì")
r = 4
End Select
Call Cerca
D = DateAdd("d", r, Worksheets("Lunedì").Cells(1, 8))
If TARGET.Cells.Count = 1 And TARGET(1) <> "" And Not Intersect(TARGET, Range("C4:C100")) Is Nothing Then
If IsDate(Range("AA" & TARGET.Row)) Then
I = TARGET.Row
U = Cells(I, 29)
s = DateAdd("d", U, Cells(TARGET.Row, 27))
If s <= D Then
Call InRITARDO(I, 0)
Else: Call InTEMPO(I, 0)
End If
End If
End If
If TARGET.Cells.Count = 1 And TARGET(1) <> "" And Not Intersect(TARGET, Range("Q4:Q100")) Is Nothing Then
If IsDate(Range("AA" & TARGET.Row)) Then
I = TARGET.Row
U = Cells(I, 29)
s = DateAdd("d", U, Cells(TARGET.Row, 27))
If s <= Date Then
Call InRITARDO2(I, 0)
Else: Call InTEMPO2(I, 0)
End If
End If
End If
' If Target.Cells.Count = 1 And Target(1) <> "" And Not Intersect(Target, Range("N4:N100")) Is Nothing Then
' If IsDate(Range("N" & Target.Row)) Then
' I = Target.Row
' If S <= Date Then
' Call InRITARDO2(I, 0)
' End If
'End If
' End If
If TARGET.Cells.Count = 1 And TARGET(1) <> "" And Not Intersect(TARGET, Range("AG4:AG100")) Is Nothing Then
If IsDate(Range("BE" & TARGET.Row)) Then
I = TARGET.Row
s = Cells(TARGET.Row, 57)
If s <= D Then
Call InRITARDO(I, 30)
Else: Call InTEMPO(I, 30)
End If
End If
End If
If TARGET.Cells.Count = 1 And TARGET(1) <> "" And Not Intersect(TARGET, Range("AU4:AU100")) Is Nothing Then
If IsDate(Range("BE" & TARGET.Row)) Then
I = TARGET.Row
U = Cells(I, 59)
s = DateAdd("d", U, Cells(TARGET.Row, 57))
If s <= Date Then
Call InRITARDO2(I, 30)
Else: Call InTEMPO2(I, 30)
End If
End If
End If
' If Target.Cells.Count = 1 And Target(1) <> "" And Not Intersect(Target, Range("AH4:AH100")) Is Nothing Then
' If IsDate(Range("BE" & Target.Row)) Then
' I = Target.Row
'
' Call InRITARDO2(I, 30)
' End If
'End If
End Sub
|
