Ciao ho aggiunto un avviso/msgbox
avviso = MsgBox("Sign. " & Environ("UserName") & Chr(13) & "inserisco articolo < " & _
num3 & " > in pos. < " & num1 & "-" & num2 & " >?", _
vbInformation + vbYesNo + vbDefaultButton2, "AVVISO")
If avviso = vbNo Then
Exit Sub
End If
ma qui non esce 00/01/02 ma 1/2/3 ecc...
Option Explicit
Sub Aggiorna_Articoli()
ActiveSheet.Unprotect "123456"
Dim sh1 As Worksheet
Dim sh2 As Worksheet
Dim cellaPos ' As Range
Dim cellaArt
Dim pos As String
Dim articolo As Variant
Dim quantità As Variant
Dim num1, num2, num3 As String
Dim avviso As String
num1 = Foglio8.Range("D3").Value 'pos1
num2 = Foglio8.Range("F3").Value 'pos2
num3 = Foglio8.Range("D4").Value 'art
avviso = MsgBox("Sign. " & Environ("UserName") & Chr(13) & "inserisco articolo < " & _
num3 & " > in pos. < " & num1 & "-" & num2 & " >?", _
vbInformation + vbYesNo + vbDefaultButton2, "AVVISO")
If avviso = vbNo Then
Exit Sub
End If
Set sh1 = Sheets("nuovo_articolo")
Set sh2 = Sheets("articoli")
With sh1
pos = .Range("D3") & .Range("E3") & Format(.Range("F3"), "00") 'costruisci il codice pos
articolo = .Range("D4")
quantità = .Range("D5")
End With
With sh2
Set cellaPos = .Range("A6:A2604").Find(What:=pos, LookIn:=xlValues, LookAt:=xlWhole) 'cerca il pos
Set cellaArt = .Range("B6:B2604").Find(What:=articolo, LookIn:=xlValues, LookAt:=xlWhole) 'cerca l'articolo
If Not cellaArt Is Nothing Then ' articolo già presente
MsgBox "articolo già presente in foglio articoli in Pos. " & .Cells(cellaArt.row, 1) 'l'articolo già esiste
ActiveSheet.Protect "123456" '<=AGGIUNTA
Exit Sub
End If
If .Cells(cellaPos.row, 2) = "" Then 'se colonna B è vuota ...
.Cells(cellaPos.row, 2) = articolo '... inserisci l'articolo
.Cells(cellaPos.row, 7) = quantità '... inserisci la quantità
MsgBox "magazzino aggiornato" 'operazione correttamente completata
Else
MsgBox "posizione non libera, trovato articolo " & .Cells(cellaPos.row, 2) 'la colonna B è già impegnata
End If
End With
ActiveSheet.Protect "123456"
End Sub
____________________________
versione excel 365 ufficio
versione excel 2007 casa