Pagina precedente | 1 | Pagina successiva
Vota | Stampa | Notifica email    
Autore

Message box dinamico nel riassumere i dati

Ultimo Aggiornamento: 26/03/2017 17:42
Post: 129
Registrato il: 13/12/2015
Città: MILANO
Età: 58
Utente Junior
2010
OFFLINE
23/03/2017 06:47

Ciao a tutti,
vorrei riassumere i dati digitati dall'operatore con message box.
Esempio del dato atteso:
Nel giorno 01/01/2017, io ho effettuato il 1°turno sull'impianto R1 quindi nella riga 3 compilo:
B3 per il numero di pezzi prodotti
C3 per il mio numero operatore
(per il 2° turno sarebbero le celle D3 e E3, etc, etc)

Quindi controllo:
1)che i dati siano SEMPRE compilati entrambi per rispettivo turno
2) Message Box si attiva quando entrambi i campi sono compilati (giorno e turno)
3)e se possibile nella message box aggiungo al numero operatore digitato (C3) il nome dello prelevato nel foglio Legenda ( nel nostro caso operatore 2 Pippo) e poi riassumo il tutto.

In maniera parziale e statica [SM=g27818] , io sono arrivato a questo:
Sub Messaggio() 
Dim Rst As String Dim Cella As Range     
Rst = Rst & "Confermi i seguenti dati? :" & vbLf & vbLf     
Rst = Rst & "Operatore:" & " " & Sheets("Anno").Range("C3") & vbLf & vbLf     
Rst = Rst & "Sull'impianto:" & " " & Sheets("Anno").Range("B1") & vbLf     
Rst = Rst & "Hai prodotto:" & " " & Sheets("Anno").Range("B3") & vbLf & vbLf
Rst = Rst & "Nel turno:" & " " & Sheets("Anno").Range("B2") & vbLf     
Rst = Rst & "del giorno:" & " " & Sheets("Anno").Range("A3") & vbLf & vbLf 
MsgBox Rst, vbInformation + vbYesNo  
End Sub


Grazie in anticipo per l'aiuto.

PS non ho usato Userform per averlo più friendly possibile e comunque che "giri" su excel 2003
[Modificato da BG66 23/03/2017 06:52]
BG66
Excel 2010
Post: 1.137
Registrato il: 06/04/2013
Utente Veteran
2010
OFFLINE
25/03/2017 11:08

Ciao
è un po' rigida la struttura, pertanto non puoi inserire colonne nel mezzo, eventualmente solo estendere il medesimo schema sulla destra (cioè aggiungere R4 - R5 - ecc con la medesima struttura).
Questo perché viene valutato dalla routine se ti trovi su una colonna dispari (operatore) o pari (poduzione).

Testala per bene. Se serve commento la macro....

saluti
[Modificato da dodo47 25/03/2017 11:10]
Domenico
Win 10 - Excel 2016
Post: 129
Registrato il: 13/12/2015
Città: MILANO
Età: 58
Utente Junior
2010
OFFLINE
25/03/2017 21:00

[RISOLTO]
Ciao Domenico,
và benissimo e provo ad approfondirla.

E per darti il giusto merito, pubblico il tutto:
 Private Sub Worksheet_Change(ByVal Target As Range) 
If Not Intersect(Target, Range("B:S")) Is Nothing Then     
If Target.Count > 1 Then Exit Sub     
Application.EnableEvents = False     
c = Target.Column     
r = Target.Row     
If Cells(1, c) <> "" Then         
impianto = Cells(1, c)     
Else         
impianto = Cells(1, c).End(xlToLeft).Value     
End If     
k = 0     
If c Mod 2 <> 0 Then         
If Cells(r, c - 1) <> "" And Cells(r, c) <> "" Then             
k = 1             
turno = Cells(2, c - 1)             
operatore = Cells(r, c)             
produzione = Cells(r, c - 1)         
End If     
ElseIf Cells(r, c) <> "" And Cells(r, c + 1) <> "" Then
k = 1
turno = Cells(2, c)         
operatore = Cells(r, c + 1)         
produzione = Cells(r, c)     
End If     
If k = 1 Then     
Rst = Rst & "Confermi i seguenti dati? :" & vbLf & vbLf     
Rst = Rst & "Operatore:" & " " & operatore & vbLf & vbLf     
Rst = Rst & "Sull'impianto:" & " " & impianto & vbLf     
Rst = Rst & "Hai prodotto:" & " " & produzione & vbLf & vbLf     
Rst = Rst & "Nel turno:" & " " & turno & vbLf     
Rst = Rst & "del giorno:" & " " & Cells(r, 1) & vbLf & vbLf     
MsgBox Rst, vbInformation + vbYesNo     
End If 
End If 
Application.EnableEvents = True 
End Sub


Grazie tanto.

[Modificato da BG66 25/03/2017 21:08]
BG66
Excel 2010
Post: 1.139
Registrato il: 06/04/2013
Utente Veteran
2010
OFFLINE
26/03/2017 11:04

Ciao e grazie per il riscontro...ma il mio codice è indentato!!!

Prendete questa buona abitudine, costa poco e rende molto.

saluti

Domenico
Win 10 - Excel 2016
Post: 130
Registrato il: 13/12/2015
Città: MILANO
Età: 58
Utente Junior
2010
OFFLINE
26/03/2017 11:53

Ciao Domenico,
ho provato a mantenere l'indentatura ma quando carico gli script sul forum usando CODE si perde ([SM=g27833] )

Buona domenica
[Modificato da BG66 26/03/2017 11:54]
BG66
Excel 2010
Post: 1.141
Registrato il: 06/04/2013
Utente Veteran
2010
OFFLINE
26/03/2017 17:42

Ciao
usa [ TESTO ].... [/ TESTO ]

Senza spazi

saluti

Domenico
Win 10 - Excel 2016
Vota: 15MediaObject5,0016 1
Amministra Discussione: | Chiudi | Sposta | Cancella | Modifica | Notifica email Pagina precedente | 1 | Pagina successiva
Nuova Discussione
 | 
Rispondi
Cerca nel forum
Tag discussione
Discussioni Simili   [vedi tutte]
Feed | Forum | Bacheca | Album | Utenti | Cerca | Login | Registrati | Amministra
Tutti gli orari sono GMT+01:00. Adesso sono le 13:56. Versione: Stampabile | Mobile | Regolamento | Privacy
FreeForumZone [v.6.1] - Copyright © 2000-2024 FFZ srl - www.freeforumzone.com