Ciao,
non so se è la migliore soluzione.
Ho pensato a un funzione "blocca pulsante" se la macro è stata avviata 1 volta:
'===============================================================================
Public flag As Integer
Option Explicit
If flag = 1 Then Exit Sub
Dim path_fisso As String
Dim commessa As String
Dim file As String
Dim avviso As String
Sub ricerca_1()
Dim WK1 As Workbook
Set WK1 = ThisWorkbook
If ActiveSheet.Range("B2") = "" Or ActiveSheet.Range("C3") = "file non presente" Then
avviso = MsgBox("Sign. " & Environ("UserName") & "" _
& Chr(13) & "dati non disponibili!", _
vbCritical, "ERRORE")
Exit Sub
End If
commessa = ActiveSheet.Range("B2").Value
Workbooks.OpenDatabase Filename:= _
"\\xxx_xxx\maxxxpxx\TOPxxx\Maxxx\xxx\" & commessa & "\maxxxx.mdb", CommandText _
:=Array("Sx1"), CommandType:=xlCmdTable, ImportDataAs:=xlTable
ActiveWorkbook.SaveAs Filename:=WK1.Path & "\" & "Cartel1.xlsx", _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Workbooks.OpenDatabase Filename:= _
"\\xxx_xxx\maxxxpxx\TOPxxx\Maxxx\xxx\" & commessa & "\maxxxx.mdb", CommandText _
:=Array("Sx2"), CommandType:=xlCmdTable, ImportDataAs:=xlTable
ActiveWorkbook.SaveAs Filename:=WK1.Path & "\" & "Cartel2.xlsx", _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
'blocco qui?
ThisWorkbook.Sheets("ricerca").Activate
flag=1
End Sub
'===============================================================================
solo se possibile è inserire un avviso "tabelle già inserite" se clicco ancora nel pulsante.
e che poi si inserisca in una cella del foglio E7 "tabelle inserite"
[Modificato da maxma62 24/06/2018 09:04]
____________________________
versione excel 365 ufficio
versione excel 2007 casa