Condividi:        

[Excel2013] Conversione dati da textbox a foglio

Vuoi potenziare i tuoi documenti Word? Non sai come si fa una macro in Excel? Devi creare una presentazione in PowerPoint?
Oppure sei passato a OpenOffice e non sei sicuro di come lavorare al meglio?

Moderatori: Anthony47, Flash30005

[Excel2013] Conversione dati da textbox a foglio

Postdi fastbike73 » 28/11/14 16:54

Buonasera, sperando di essere più fortunato con questa domanda,
vi chiedo cortesemente di spiegarmi come posso trasferire dalla textbox
al foglio il formato prescelto.
Nella fattispecie ho specificato il formato nella textbox con questo codice:

Codice: Seleziona tutto
Private Sub TextBox105_afterupdate()
TextBox105 = Format(TextBox105, "dd/mm/yyyy")
End Sub


Vorrei che lo stesso formato venisse trasferito anche nel foglio per tutta la colonna che fa riferimento al campo Data.

Stessa cosa per le textbox in cui scrivo valori:
Codice: Seleziona tutto
Private Sub TextBox305_afterupdate()
TextBox305 = Format(TextBox305, "€ #,###.00")
End Sub


Fiducioso del vostro aiuto, vi ringrazio sin d'ora!!!
fastbike73
Win 10 & Office365
Filemaker Pro v. 13
fastbike73
Utente Senior
 
Post: 256
Iscritto il: 23/04/14 10:54

Sponsor
 

Re: [Excel2013] Conversione dati da textbox a foglio

Postdi Anthony47 » 29/11/14 01:51

Devi dividere il problema in due step:
1-assicurarti che "le stringhe di testo" presente nei TextBox vengano trasformate nelle grandezze giuste prima di essere caricate all' interno di una cella.
Per questo userai le funzioni di conversione, es CDate per convertire la stringa in Data e CLng per convertire le stringhe in "numeri interi". Consulta l' help on line alla voce "Funzioni di conversione del tipo" per sapere quali funzioni sono disponibili.

2-una volta che la cella contiene una certa tipologia di informazioni, applicarvi una formattazione a piacere per avere il dato visualizzato secondo propri gusti estetici o esigenze funzionali.
Per questo scopo userai il registratore di macro per ottenere le sequenza di codice idonee allo scopo.

E se non risolvi con questi spunti scrivi ancora, chiarendo dove sei arrivato e dove invece ti sei arenato.

Ciao
Avatar utente
Anthony47
Moderatore
 
Post: 19220
Iscritto il: 21/03/06 16:03
Località: Ivrea

Re: [Excel2013] Conversione dati da textbox a foglio

Postdi fastbike73 » 10/12/14 09:26

Anthony47 ha scritto:Devi dividere il problema in due step:
1-assicurarti che "le stringhe di testo" presente nei TextBox vengano trasformate nelle grandezze giuste prima di essere caricate all' interno di una cella.
Per questo userai le funzioni di conversione, es CDate per convertire la stringa in Data e CLng per convertire le stringhe in "numeri interi". Consulta l' help on line alla voce "Funzioni di conversione del tipo" per sapere quali funzioni sono disponibili.

2-una volta che la cella contiene una certa tipologia di informazioni, applicarvi una formattazione a piacere per avere il dato visualizzato secondo propri gusti estetici o esigenze funzionali.
Per questo scopo userai il registratore di macro per ottenere le sequenza di codice idonee allo scopo.

E se non risolvi con questi spunti scrivi ancora, chiarendo dove sei arrivato e dove invece ti sei arenato.

Ciao


Buongiorno Anthony, per problemi di salute ti rispondo soltanto adesso. Ho eseguito il punto 1 del tuo suggerimento
impostando come segue il formato di ogni textbox in cui i dati non devono essere testo:

Codice: Seleziona tutto
Private Sub CommandButton2_Click()
If TextBox102 = "" Then
MsgBox "Devi inserire il numero del Documento"
TextBox102.SetFocus
Exit Sub
End If
Dim irisposta As Integer
irisposta = MsgBox("Confermi la registrazione" _
& " di " & TextBox102.Value & " ?", vbYesNo)
If irisposta = vbYes Then
Range("B1").Value = "-"
Range("B1").End(xlDown).Offset(1, 0).Select
ActiveCell.Value = TextBox102
ActiveCell.Offset(0, 1).Value = TextBox103
ActiveCell.Offset(0, 2).Value = TextBox104
ActiveCell.Offset(0, 3).Value = CDate(Format(TextBox105, "dd/mm/yyyy"))
ActiveCell.Offset(0, 4).Value = TextBox106
ActiveCell.Offset(0, 5).Value = TextBox107
ActiveCell.Offset(0, 6).Value = TextBox108
ActiveCell.Offset(0, 7).Value = CDate(Format(TextBox109, "dd/mm/yyyy"))
ActiveCell.Offset(0, 8).Value = TextBox110
ActiveCell.Offset(0, 9).Value = TextBox111
ActiveCell.Offset(0, 10).Value = TextBox112
ActiveCell.Offset(0, 11).Value = TextBox113
ActiveCell.Offset(0, 12).Value = TextBox114
ActiveCell.Offset(0, 13).Value = TextBox115
ActiveCell.Offset(0, 14).Value = TextBox116
ActiveCell.Offset(0, 15).Value = CDbl(Format(TextBox201, "€#,###.00"))
ActiveCell.Offset(0, 16).Value = CDbl(Format(TextBox202, "€#,###.00"))
ActiveCell.Offset(0, 17).Value = CDbl(Format(TextBox203, "€#,###.00"))
ActiveCell.Offset(0, 18).Value = CDbl(Format(TextBox204, "€#,###.00"))
ActiveCell.Offset(0, 19).Value = CDbl(Format(TextBox205, "€#,###.00"))
ActiveCell.Offset(0, 20).Value = CDbl(Format(TextBox206, "€#,###.00"))
ActiveCell.Offset(0, 21).Value = CDbl(Format(TextBox207, "€#,###.00"))
ActiveCell.Offset(0, 22).Value = CDbl(Format(TextBox208, "€#,###.00"))
ActiveCell.Offset(0, 23).Value = CDbl(Format(TextBox209, "€#,###.00"))
ActiveCell.Offset(0, 24).Value = CDbl(Format(TextBox210, "€#,###.00"))
ActiveCell.Offset(0, 25).Value = TextBox301
ActiveCell.Offset(0, 26).Value = TextBox302
ActiveCell.Offset(0, 27).Value = TextBox303
ActiveCell.Offset(0, 28).Value = CDate(Format(TextBox304, "dd/mm/yyyy"))
ActiveCell.Offset(0, 29).Value = CDbl(Format(TextBox305, "€#,###.00"))

MsgBox "Registrazione eseguita!!"

TextBox102 = ""
TextBox103 = ""
TextBox104 = ""
TextBox105 = ""
TextBox106 = ""
TextBox107 = ""
TextBox108 = ""
TextBox109 = ""
TextBox110 = ""
TextBox111 = ""
TextBox112 = ""
TextBox113 = ""
TextBox114 = ""
TextBox115 = ""
TextBox116 = ""
TextBox201 = ""
TextBox202 = ""
TextBox203 = ""
TextBox204 = ""
TextBox205 = ""
TextBox206 = ""
TextBox207 = ""
TextBox208 = ""
TextBox209 = ""
TextBox210 = ""
TextBox301 = ""
TextBox302 = ""
TextBox303 = ""
TextBox304 = ""
TextBox305 = ""

End If
End Sub


Adesso però non ho capito bene il punto 2. Mi potresti spiegare?
Grazie 1000.
fastbike73
Win 10 & Office365
Filemaker Pro v. 13
fastbike73
Utente Senior
 
Post: 256
Iscritto il: 23/04/14 10:54

Re: [Excel2013] Conversione dati da textbox a foglio

Postdi Anthony47 » 10/12/14 15:10

Operazioni come queste sono inutili:
CDate(Format(TextBox105, "dd/mm/yyyy"))
perche' basta ad esempio
Codice: Seleziona tutto
CDate(TextBox105)

(CDate restituisce nella cella un valore pari a una data, perdendo il formato con cui avevi convertito la stringa).

La formattazione di tuo gradimento va applicata alla cella in cui carichi il valore; troverai il codice corrispondente tramite un Registra macro, convertendo poi il rialsultato nel tuo contesto; ad esempio:
Codice: Seleziona tutto
    ActiveCell.Offset(0, 3).NumberFormat = "dd-mmm-yy"


Ciao
Avatar utente
Anthony47
Moderatore
 
Post: 19220
Iscritto il: 21/03/06 16:03
Località: Ivrea

Re: [Excel2013] Conversione dati da textbox a foglio

Postdi fastbike73 » 10/12/14 15:29

Anthony47 ha scritto:Operazioni come queste sono inutili:
CDate(Format(TextBox105, "dd/mm/yyyy"))
perche' basta ad esempio
Codice: Seleziona tutto
CDate(TextBox105)

(CDate restituisce nella cella un valore pari a una data, perdendo il formato con cui avevi convertito la stringa).

La formattazione di tuo gradimento va applicata alla cella in cui carichi il valore; troverai il codice corrispondente tramite un Registra macro, convertendo poi il rialsultato nel tuo contesto; ad esempio:
Codice: Seleziona tutto
    ActiveCell.Offset(0, 3).NumberFormat = "dd-mmm-yy"


Ciao


Ti ringrazio per i consigli. Provo subito e ti faccio sapere. ;)
fastbike73
Win 10 & Office365
Filemaker Pro v. 13
fastbike73
Utente Senior
 
Post: 256
Iscritto il: 23/04/14 10:54

Re: [Excel2013] Conversione dati da textbox a foglio

Postdi fastbike73 » 11/12/14 16:41

Ciao Anthony, ho eseguito i tuoi suggerimenti. Non riesco a capire però perchè mi da sempre
"Errore di Run time '13':
Tipo non corrispondente.
Riporto per intero il codice legato alla Userform con cui inserisco, modifico, cancello e cerco i record
nella speranza che ti / mi possa aiutare a capire dove sbaglio. Perdona la mia ignoranza...

Codice: Seleziona tutto
Option Explicit

Dim myForm As New Classe1
Dim bChiusura As Boolean

Private Sub ComboBox1_Change()
TextBox101.Text = ComboBox1.Text

End Sub

Per cercare di essere utile ti specifico:
1) il bottone 1 cerca i record;
2) il bottone 10, 11, 12 e 13 attivano i fogli 1, 2 ,3 e 4 ;
3) il bottone 2 inserisce record nuovi dopo la digitazione all'interno delle varie textbox;
4) il bottone 3 modifica record dopo aver effettuato la ricerca dello stesso;
5) il bottone 4 cancella il record che era stato cercato;
6) il bottone 5 e 6 servono per scorrere i record del foglio selezionato;
7) il bottone 7 esce dalla userform;
8) il bottone 8 pulisce la form dai dati presenti;
9) il bottone 9 apre la finestra "Apri" per cercare il file della cartella

Spero che questo ti possa aiutare nella lettura del codice.
Grazie.

Private Sub CommandButton1_Click()
If TextBox101 = "" Then
MsgBox "Inserisci il numero del Documento"
TextBox101.SetFocus
Exit Sub
End If
If OptionButton1.Value = True Then
primo
End If

If OptionButton2.Value = True Then
With ActiveSheet.Range("B3:B302")
Dim X As String, C, firstAddress, Y, irisposta
X = TextBox101.Value
Set C = .Find(X, LookIn:=xlValues) ', LookAt:=xlWhole
If Not C Is Nothing Then
firstAddress = C.Address
Do
C.Cells.Select
TextBox102 = C.Value ' nr.documento B
TextBox103 = C.Offset(0, 1).Value ' id documento C
TextBox104 = C.Offset(0, 2).Value ' tipo documento D
TextBox105 = C.Offset(0, 3).Value ' data ricezione E
TextBox106 = C.Offset(0, 4).Value ' consegnato a F
TextBox107 = C.Offset(0, 5).Value ' registrato da G
TextBox108 = C.Offset(0, 6).Value ' soc/pers H
TextBox109 = C.Offset(0, 7).Value ' data scadenza I
TextBox110 = C.Offset(0, 8).Value ' ente emittente J
TextBox111 = C.Offset(0, 9).Value ' ufficio competente K
TextBox112 = C.Offset(0, 10).Value ' anno ruolo L
TextBox113 = C.Offset(0, 11).Value ' anno tributo M
TextBox114 = C.Offset(0, 12).Value ' causale tributo N
TextBox115 = C.Offset(0, 13).Value ' apri documento O
TextBox116 = C.Offset(0, 14).Value ' riscontro/note P
TextBox201 = C.Offset(0, 15).Value ' importo a carico Q
TextBox202 = C.Offset(0, 16).Value ' sgravio R
TextBox203 = C.Offset(0, 17).Value ' importo pagato S
TextBox204 = C.Offset(0, 18).Value ' residuo T
TextBox205 = C.Offset(0, 19).Value ' totale U
TextBox206 = C.Offset(0, 20).Value ' aggio V
TextBox207 = C.Offset(0, 21).Value ' interessi di mora W
TextBox208 = C.Offset(0, 22).Value ' diritti e spese X
TextBox209 = C.Offset(0, 23).Value ' totale cartella Y
TextBox210 = C.Offset(0, 24).Value ' saldo pagato Z
TextBox301 = C.Offset(0, 25).Value ' nr.cartella AA
TextBox302 = C.Offset(0, 26).Value ' intimazione pagamento AB
TextBox303 = C.Offset(0, 27).Value ' agente della riscossione AC
TextBox304 = C.Offset(0, 28).Value ' data notifica AD
TextBox305 = C.Offset(0, 29).Value ' importo da pagare AE

Y = C.Value
irisposta = MsgBox("Trovato " & Y & " . Vuoi fermarti ?", vbYesNo)
If irisposta = vbYes Then 'se rispondo si allora
GoTo 10 'esco dal ciclo
End If
Set C = .FindNext(C)
Loop While Not C Is Nothing And C.Address <> firstAddress

Else
MsgBox "Documento non trovato"
End If
10:
End With
End If
End Sub

Private Sub CommandButton10_Click()
Sheets(1).Select

If ActiveSheet.Name = ("Foglio1") Then
TextBox102 = ""
TextBox103 = ""
TextBox104 = ""
TextBox105 = ""
TextBox106 = ""
TextBox107 = ""
TextBox108 = ""
TextBox109 = ""
TextBox110 = ""
TextBox111 = ""
TextBox112 = ""
TextBox113 = ""
TextBox114 = ""
TextBox115 = ""
TextBox116 = ""
TextBox201 = ""
TextBox202 = ""
TextBox203 = ""
TextBox204 = ""
TextBox205 = ""
TextBox206 = ""
TextBox207 = ""
TextBox208 = ""
TextBox209 = ""
TextBox210 = ""
TextBox301 = ""
TextBox302 = ""
TextBox303 = ""
TextBox304 = ""
TextBox305 = ""
Userform1.ComboBox1.RowSource = ""
Userform1.ComboBox1.RowSource = "B3:B302"
CheckBox1.Value = True
CheckBox2.Value = False
CheckBox3.Value = False
CheckBox4.Value = False

End If
End Sub

Private Sub CommandButton11_Click()
Sheets(2).Select

If ActiveSheet.Name = ("Foglio2") Then
TextBox102 = ""
TextBox103 = ""
TextBox104 = ""
TextBox105 = ""
TextBox106 = ""
TextBox107 = ""
TextBox108 = ""
TextBox109 = ""
TextBox110 = ""
TextBox111 = ""
TextBox112 = ""
TextBox113 = ""
TextBox114 = ""
TextBox115 = ""
TextBox116 = ""
TextBox201 = ""
TextBox202 = ""
TextBox203 = ""
TextBox204 = ""
TextBox205 = ""
TextBox206 = ""
TextBox207 = ""
TextBox208 = ""
TextBox209 = ""
TextBox210 = ""
TextBox301 = ""
TextBox302 = ""
TextBox303 = ""
TextBox304 = ""
TextBox305 = ""
Userform1.ComboBox1.RowSource = ""
Userform1.ComboBox1.RowSource = "B3:B302"
CheckBox1.Value = False
CheckBox2.Value = True
CheckBox3.Value = False
CheckBox4.Value = False

End If
End Sub

Private Sub CommandButton12_Click()
Sheets(3).Select

If ActiveSheet.Name = ("Foglio3") Then
TextBox102 = ""
TextBox103 = ""
TextBox104 = ""
TextBox105 = ""
TextBox106 = ""
TextBox107 = ""
TextBox108 = ""
TextBox109 = ""
TextBox110 = ""
TextBox111 = ""
TextBox112 = ""
TextBox113 = ""
TextBox114 = ""
TextBox115 = ""
TextBox116 = ""
TextBox201 = ""
TextBox202 = ""
TextBox203 = ""
TextBox204 = ""
TextBox205 = ""
TextBox206 = ""
TextBox207 = ""
TextBox208 = ""
TextBox209 = ""
TextBox210 = ""
TextBox301 = ""
TextBox302 = ""
TextBox303 = ""
TextBox304 = ""
TextBox305 = ""
Userform1.ComboBox1.RowSource = ""
Userform1.ComboBox1.RowSource = "B3:B302"
CheckBox1.Value = False
CheckBox2.Value = False
CheckBox3.Value = True
CheckBox4.Value = False

End If
End Sub

Private Sub CommandButton13_Click()
Sheets(4).Select

If ActiveSheet.Name = ("Foglio4") Then
TextBox102 = ""
TextBox103 = ""
TextBox104 = ""
TextBox105 = ""
TextBox106 = ""
TextBox107 = ""
TextBox108 = ""
TextBox109 = ""
TextBox110 = ""
TextBox111 = ""
TextBox112 = ""
TextBox113 = ""
TextBox114 = ""
TextBox115 = ""
TextBox116 = ""
TextBox201 = ""
TextBox202 = ""
TextBox203 = ""
TextBox204 = ""
TextBox205 = ""
TextBox206 = ""
TextBox207 = ""
TextBox208 = ""
TextBox209 = ""
TextBox210 = ""
TextBox301 = ""
TextBox302 = ""
TextBox303 = ""
TextBox304 = ""
TextBox305 = ""
Userform1.ComboBox1.RowSource = ""
Userform1.ComboBox1.RowSource = "B3:B302"
CheckBox1.Value = False
CheckBox2.Value = False
CheckBox3.Value = False
CheckBox4.Value = True

End If
End Sub

Private Sub CommandButton2_Click()
If TextBox102 = "" Then
MsgBox "Devi inserire il numero del Documento"
TextBox102.SetFocus
Exit Sub
End If
Dim irisposta As Integer
irisposta = MsgBox("Confermi la registrazione" _
& " di " & TextBox102.Value & " ?", vbYesNo)
If irisposta = vbYes Then
Range("B1").Value = "-"
Range("B1").End(xlDown).Offset(1, 0).Select
ActiveCell.Value = TextBox102
ActiveCell.Offset(0, 1).Value = TextBox103
ActiveCell.Offset(0, 2).Value = TextBox104
ActiveCell.Offset(0, 3).Value = CDate(TextBox105)
ActiveCell.Offset(0, 3).NumberFormat = "dd-mmm-yy"
ActiveCell.Offset(0, 4).Value = TextBox106
ActiveCell.Offset(0, 5).Value = TextBox107
ActiveCell.Offset(0, 6).Value = TextBox108
ActiveCell.Offset(0, 7).Value = CDate(TextBox109)
ActiveCell.Offset(0, 7).NumberFormat = "dd-mmm-yy"
ActiveCell.Offset(0, 8).Value = TextBox110
ActiveCell.Offset(0, 9).Value = TextBox111
ActiveCell.Offset(0, 10).Value = TextBox112
ActiveCell.Offset(0, 11).Value = TextBox113
ActiveCell.Offset(0, 12).Value = TextBox114
ActiveCell.Offset(0, 13).Value = TextBox115
ActiveCell.Offset(0, 14).Value = TextBox116
ActiveCell.Offset(0, 15).Value = CDbl(Format(TextBox201, "#,###,00"))
ActiveCell.Offset(0, 16).Value = CDbl(Format(TextBox202, "#,###.00"))
ActiveCell.Offset(0, 17).Value = CDbl(Format(TextBox203, "#,###.00"))
ActiveCell.Offset(0, 18).Value = CDbl(Format(TextBox204, "#,###.00"))
ActiveCell.Offset(0, 19).Value = CDbl(Format(TextBox205, "#,###.00"))
ActiveCell.Offset(0, 20).Value = CDbl(Format(TextBox206, "#,###.00"))
ActiveCell.Offset(0, 21).Value = CDbl(Format(TextBox207, "#,###.00"))
ActiveCell.Offset(0, 22).Value = CDbl(Format(TextBox208, "#,###.00"))
ActiveCell.Offset(0, 23).Value = CDbl(Format(TextBox209, "#,###.00"))
ActiveCell.Offset(0, 24).Value = CDbl(Format(TextBox210, "#,###.00"))
ActiveCell.Offset(0, 25).Value = TextBox301
ActiveCell.Offset(0, 26).Value = TextBox302
ActiveCell.Offset(0, 27).Value = TextBox303
ActiveCell.Offset(0, 28).Value = CDate(TextBox304)
ActiveCell.Offset(0, 28).NumberFormat = "dd-mmm-yy"
ActiveCell.Offset(0, 29).Value = CDbl(Format(TextBox305, "#,###.00"))

MsgBox "Registrazione eseguita!!"

TextBox102 = ""
TextBox103 = ""
TextBox104 = ""
TextBox105 = ""
TextBox106 = ""
TextBox107 = ""
TextBox108 = ""
TextBox109 = ""
TextBox110 = ""
TextBox111 = ""
TextBox112 = ""
TextBox113 = ""
TextBox114 = ""
TextBox115 = ""
TextBox116 = ""
TextBox201 = ""
TextBox202 = ""
TextBox203 = ""
TextBox204 = ""
TextBox205 = ""
TextBox206 = ""
TextBox207 = ""
TextBox208 = ""
TextBox209 = ""
TextBox210 = ""
TextBox301 = ""
TextBox302 = ""
TextBox303 = ""
TextBox304 = ""
TextBox305 = ""

End If
End Sub

Private Sub CommandButton3_Click()
If TextBox102 = "" Then
MsgBox "Devi cercare un Documento per usare il pulsante modifica"
Exit Sub
End If
ActiveCell.Offset(0, 1).Value = TextBox103
ActiveCell.Offset(0, 2).Value = TextBox104
ActiveCell.Offset(0, 3).Value = CDate(TextBox105)
ActiveCell.Offset(0, 3).NumberFormat = "dd-mmm-yy"
ActiveCell.Offset(0, 4).Value = TextBox106
ActiveCell.Offset(0, 5).Value = TextBox107
ActiveCell.Offset(0, 6).Value = TextBox108
ActiveCell.Offset(0, 7).Value = CDate(TextBox109)
ActiveCell.Offset(0, 7).NumberFormat = "dd-mmm-yy"
ActiveCell.Offset(0, 8).Value = TextBox110
ActiveCell.Offset(0, 9).Value = TextBox111
ActiveCell.Offset(0, 10).Value = TextBox112
ActiveCell.Offset(0, 11).Value = TextBox113
ActiveCell.Offset(0, 12).Value = TextBox114
ActiveCell.Offset(0, 13).Value = TextBox115
ActiveCell.Offset(0, 14).Value = TextBox116
ActiveCell.Offset(0, 15).Value = CDbl(Format(TextBox201, "#,###,00"))
ActiveCell.Offset(0, 16).Value = CDbl(Format(TextBox202, "#,###.00"))
ActiveCell.Offset(0, 17).Value = CDbl(Format(TextBox203, "#,###.00"))
ActiveCell.Offset(0, 18).Value = CDbl(Format(TextBox204, "#,###.00"))
ActiveCell.Offset(0, 19).Value = CDbl(Format(TextBox205, "#,###.00"))
ActiveCell.Offset(0, 20).Value = CDbl(Format(TextBox206, "#,###.00"))
ActiveCell.Offset(0, 21).Value = CDbl(Format(TextBox207, "#,###.00"))
ActiveCell.Offset(0, 22).Value = CDbl(Format(TextBox208, "#,###.00"))
ActiveCell.Offset(0, 23).Value = CDbl(Format(TextBox209, "#,###.00"))
ActiveCell.Offset(0, 24).Value = CDbl(Format(TextBox210, "#,###.00"))
ActiveCell.Offset(0, 25).Value = TextBox301
ActiveCell.Offset(0, 26).Value = TextBox302
ActiveCell.Offset(0, 27).Value = TextBox303
ActiveCell.Offset(0, 28).Value = CDate(TextBox304)
ActiveCell.Offset(0, 28).NumberFormat = "dd-mmm-yy"
ActiveCell.Offset(0, 29).Value = CDbl(Format(TextBox305, "#,###.00"))

MsgBox "Ok! Eseguito!"



End Sub

Private Sub CommandButton4_Click()
If TextBox102 = "" Then Exit Sub
ActiveCell.Select
Dim irisposta As Integer
irisposta = MsgBox("Vuoi cancellare il Documento nr.: " & ActiveCell.Value & "?", vbYesNo)
If irisposta = vbYes Then
ActiveCell.EntireRow.Delete

Dim CA As Object
Range("A3:A302").ClearContents
Range("A3").Value = 1
For Each CA In Range("A3:A302")
If CA.Offset(1, 0) = "" Then
CA.Offset(1, 0) = CA + 1
End If
Next
End If


End Sub

Private Sub CommandButton5_Click()
If ActiveCell.Offset(-1, 0).Value = "Nr.documento" Then
MsgBox "Inizio elenco"
Exit Sub
End If

ActiveCell.Offset(-1, 0).Select
TextBox102 = ActiveCell.Offset(0, 0).Value
TextBox103 = ActiveCell.Offset(0, 1).Value
TextBox104 = ActiveCell.Offset(0, 2).Value
TextBox105 = ActiveCell.Offset(0, 3).Value
TextBox106 = ActiveCell.Offset(0, 4).Value
TextBox107 = ActiveCell.Offset(0, 5).Value
TextBox108 = ActiveCell.Offset(0, 6).Value
TextBox109 = ActiveCell.Offset(0, 7).Value
TextBox110 = ActiveCell.Offset(0, 8).Value
TextBox111 = ActiveCell.Offset(0, 9).Value
TextBox112 = ActiveCell.Offset(0, 10).Value
TextBox113 = ActiveCell.Offset(0, 11).Value
TextBox114 = ActiveCell.Offset(0, 12).Value
TextBox115 = ActiveCell.Offset(0, 13).Value
TextBox116 = ActiveCell.Offset(0, 14).Value
TextBox201 = ActiveCell.Offset(0, 15).Value
TextBox202 = ActiveCell.Offset(0, 16).Value
TextBox203 = ActiveCell.Offset(0, 17).Value
TextBox204 = ActiveCell.Offset(0, 18).Value
TextBox205 = ActiveCell.Offset(0, 19).Value
TextBox206 = ActiveCell.Offset(0, 20).Value
TextBox207 = ActiveCell.Offset(0, 21).Value
TextBox208 = ActiveCell.Offset(0, 22).Value
TextBox209 = ActiveCell.Offset(0, 23).Value
TextBox210 = ActiveCell.Offset(0, 24).Value
TextBox301 = ActiveCell.Offset(0, 25).Value
TextBox302 = ActiveCell.Offset(0, 26).Value
TextBox303 = ActiveCell.Offset(0, 27).Value
TextBox304 = ActiveCell.Offset(0, 28).Value
TextBox305 = ActiveCell.Offset(0, 29).Value

End Sub

Private Sub CommandButton6_Click()
If ActiveCell.Offset(1, 0).Value = "" Then
MsgBox "Fine elenco"
Exit Sub
End If
ActiveCell.Offset(1, 0).Select
TextBox102 = ActiveCell.Value
TextBox103 = ActiveCell.Offset(0, 1).Value
TextBox104 = ActiveCell.Offset(0, 2).Value
TextBox105 = ActiveCell.Offset(0, 3).Value
TextBox106 = ActiveCell.Offset(0, 4).Value
TextBox107 = ActiveCell.Offset(0, 5).Value
TextBox108 = ActiveCell.Offset(0, 6).Value
TextBox109 = ActiveCell.Offset(0, 7).Value
TextBox110 = ActiveCell.Offset(0, 8).Value
TextBox111 = ActiveCell.Offset(0, 9).Value
TextBox112 = ActiveCell.Offset(0, 10).Value
TextBox113 = ActiveCell.Offset(0, 11).Value
TextBox114 = ActiveCell.Offset(0, 12).Value
TextBox115 = ActiveCell.Offset(0, 13).Value
TextBox116 = ActiveCell.Offset(0, 14).Value
TextBox201 = ActiveCell.Offset(0, 15).Value
TextBox202 = ActiveCell.Offset(0, 16).Value
TextBox203 = ActiveCell.Offset(0, 17).Value
TextBox204 = ActiveCell.Offset(0, 18).Value
TextBox205 = ActiveCell.Offset(0, 19).Value
TextBox206 = ActiveCell.Offset(0, 20).Value
TextBox207 = ActiveCell.Offset(0, 21).Value
TextBox208 = ActiveCell.Offset(0, 22).Value
TextBox209 = ActiveCell.Offset(0, 23).Value
TextBox210 = ActiveCell.Offset(0, 24).Value
TextBox301 = ActiveCell.Offset(0, 25).Value
TextBox302 = ActiveCell.Offset(0, 26).Value
TextBox303 = ActiveCell.Offset(0, 27).Value
TextBox304 = ActiveCell.Offset(0, 28).Value
TextBox305 = ActiveCell.Offset(0, 29).Value

End Sub

Private Sub CommandButton7_Click()
Dim cartella As Variant

For Each cartella In Application.Workbooks
cartella.Save
Next cartella
'Application.Quit
End
End Sub

Private Sub CommandButton8_Click()
TextBox101 = ""
TextBox102 = ""
TextBox103 = ""
TextBox104 = ""
TextBox105 = ""
TextBox106 = ""
TextBox107 = ""
TextBox108 = ""
TextBox109 = ""
TextBox110 = ""
TextBox111 = ""
TextBox112 = ""
TextBox113 = ""
TextBox114 = ""
TextBox115 = ""
TextBox116 = ""
TextBox201 = ""
TextBox202 = ""
TextBox203 = ""
TextBox204 = ""
TextBox205 = ""
TextBox206 = ""
TextBox207 = ""
TextBox208 = ""
TextBox209 = ""
TextBox210 = ""
TextBox301 = ""
TextBox302 = ""
TextBox303 = ""
TextBox304 = ""
TextBox305 = ""
ComboBox1 = ""

End Sub

Private Sub CommandButton9_Click()

Dim FN As String

FN = Application.GetOpenFilename("All files (*.*), *.*")

If FN = "Falso" Then Exit Sub

TextBox114.Text = FN

End Sub

Private Sub UserForm_Initialize()

  Set myForm.Form = Me
With Me
    .BorderStyle = fmBorderStyleSingle
End With
With Application
    .DisplayAlerts = False
    .WindowState = xlMaximized
End With
With Application
    Me.Top = .Top
    Me.Left = .Left
    Me.Height = .Height
    Me.Width = .Width
End With

Me.MultiPage1.Value = 0
ActiveSheet.Range("B3").Select
ComboBox1.RowSource = "B3:B302"

End Sub

Private Sub UserForm_QueryClose(cancel As Integer, CloseMode As Integer)
    If bChiusura = False Then
        cancel = False
        ThisWorkbook.Save
        Application.Quit
        ThisWorkbook.Close
    ElseIf bChiusura = True Then
        cancel = False
    End If
End Sub

Private Sub Userform_Terminate()
    Set myForm = Nothing
End Sub

Private Sub Userform_Activate()
Userform1.ComboBox1.RowSource = ""
Userform1.ComboBox1.RowSource = "B3:B302"
If ActiveSheet.Name = ("Foglio1") Then
TextBox102 = ""
TextBox103 = ""
TextBox104 = ""
TextBox105 = ""
TextBox106 = ""
TextBox107 = ""
TextBox108 = ""
TextBox109 = ""
TextBox110 = ""
TextBox111 = ""
TextBox112 = ""
TextBox113 = ""
TextBox114 = ""
TextBox115 = ""
TextBox116 = ""
TextBox201 = ""
TextBox202 = ""
TextBox203 = ""
TextBox204 = ""
TextBox205 = ""
TextBox206 = ""
TextBox207 = ""
TextBox208 = ""
TextBox209 = ""
TextBox210 = ""
TextBox301 = ""
TextBox302 = ""
TextBox303 = ""
TextBox304 = ""
TextBox305 = ""
CheckBox1.Value = True
CheckBox2.Value = False
CheckBox3.Value = False
CheckBox4.Value = False
End If

If ActiveSheet.Name = ("Foglio2") Then
TextBox102 = ""
TextBox103 = ""
TextBox104 = ""
TextBox105 = ""
TextBox106 = ""
TextBox107 = ""
TextBox108 = ""
TextBox109 = ""
TextBox110 = ""
TextBox111 = ""
TextBox112 = ""
TextBox113 = ""
TextBox114 = ""
TextBox115 = ""
TextBox116 = ""
TextBox201 = ""
TextBox202 = ""
TextBox203 = ""
TextBox204 = ""
TextBox205 = ""
TextBox206 = ""
TextBox207 = ""
TextBox208 = ""
TextBox209 = ""
TextBox210 = ""
TextBox301 = ""
TextBox302 = ""
TextBox303 = ""
TextBox304 = ""
TextBox305 = ""
CheckBox1.Value = False
CheckBox2.Value = True
CheckBox3.Value = False
CheckBox4.Value = False
End If

If ActiveSheet.Name = ("Foglio3") Then
TextBox102 = ""
TextBox103 = ""
TextBox104 = ""
TextBox105 = ""
TextBox106 = ""
TextBox107 = ""
TextBox108 = ""
TextBox109 = ""
TextBox110 = ""
TextBox111 = ""
TextBox112 = ""
TextBox113 = ""
TextBox114 = ""
TextBox115 = ""
TextBox116 = ""
TextBox201 = ""
TextBox202 = ""
TextBox203 = ""
TextBox204 = ""
TextBox205 = ""
TextBox206 = ""
TextBox207 = ""
TextBox208 = ""
TextBox209 = ""
TextBox210 = ""
TextBox301 = ""
TextBox302 = ""
TextBox303 = ""
TextBox304 = ""
TextBox305 = ""
CheckBox1.Value = False
CheckBox2.Value = False
CheckBox3.Value = True
CheckBox4.Value = False
End If

If ActiveSheet.Name = ("Foglio4") Then
TextBox102 = ""
TextBox103 = ""
TextBox104 = ""
TextBox105 = ""
TextBox106 = ""
TextBox107 = ""
TextBox108 = ""
TextBox109 = ""
TextBox110 = ""
TextBox111 = ""
TextBox112 = ""
TextBox113 = ""
TextBox114 = ""
TextBox115 = ""
TextBox116 = ""
TextBox201 = ""
TextBox202 = ""
TextBox203 = ""
TextBox204 = ""
TextBox205 = ""
TextBox206 = ""
TextBox207 = ""
TextBox208 = ""
TextBox209 = ""
TextBox210 = ""
TextBox301 = ""
TextBox302 = ""
TextBox303 = ""
TextBox304 = ""
TextBox305 = ""
CheckBox1.Value = False
CheckBox2.Value = False
CheckBox3.Value = False
CheckBox4.Value = True

End If
End Sub
fastbike73
Win 10 & Office365
Filemaker Pro v. 13
fastbike73
Utente Senior
 
Post: 256
Iscritto il: 23/04/14 10:54

Re: [Excel2013] Conversione dati da textbox a foglio

Postdi Anthony47 » 11/12/14 23:30

Si, ma quale riga va in errore e in quale momento?
Avatar utente
Anthony47
Moderatore
 
Post: 19220
Iscritto il: 21/03/06 16:03
Località: Ivrea

Re: [Excel2013] Conversione dati da textbox a foglio

Postdi fastbike73 » 12/12/14 05:27

Anthony47 ha scritto:Si, ma quale riga va in errore e in quale momento?


Buongiorno Anthony, hai ragione non ti ho specificato dove.
Dunque sia in inserimento che in modifica appena faccio click sui relativi
button mi appare il messaggio di errore che riporta alla seguente riga:

Codice: Seleziona tutto
ActiveCell.Offset(0, 15).Value = CDbl(Format(TextBox201, "#,###,00"))


Appena arrivo in ufficio ti allego l'intero file così puoi effettuare delle prove sempre dover ricreare l'ambiente
di sana pianta...
Ti ringrazio ancora. A dopo.
fastbike73
Win 10 & Office365
Filemaker Pro v. 13
fastbike73
Utente Senior
 
Post: 256
Iscritto il: 23/04/14 10:54

Re: [Excel2013] Conversione dati da textbox a foglio

Postdi Anthony47 » 12/12/14 08:48

NON DEVI usare Cdbl(Format(etc etc, ma solo Cdbl(ValoreDelTextbox)
Vale per tutte le funzioni di conversione.
Ciao
Avatar utente
Anthony47
Moderatore
 
Post: 19220
Iscritto il: 21/03/06 16:03
Località: Ivrea

Re: [Excel2013] Conversione dati da textbox a foglio

Postdi fastbike73 » 12/12/14 11:05

Anthony47 ha scritto:NON DEVI usare Cdbl(Format(etc etc, ma solo Cdbl(ValoreDelTextbox)
Vale per tutte le funzioni di conversione.
Ciao


Buongiorno Anthony, grazie ancora. Ho effettuato la modifica. Mi esce un altro errore:

"Errore di run-time '1004': errore nel metodo Save per la classe workbook

La riga in questione è la seguente:

Codice: Seleziona tutto
Private Sub CommandButton7_Click()
Dim cartella As Variant

For Each cartella In Application.Workbooks
[b]cartella.Save[/b]
Next cartella
'Application.Quit
End
End Sub



Per completezza come promesso ti allego il file.

https://www.dropbox.com/s/0udn7eftvpmdhue/Cartelle1.xlsm?dl=0
fastbike73
Win 10 & Office365
Filemaker Pro v. 13
fastbike73
Utente Senior
 
Post: 256
Iscritto il: 23/04/14 10:54

Re: [Excel2013] Conversione dati da textbox a foglio

Postdi Anthony47 » 12/12/14 23:42

Il problema della "Conversione dati da textbox a foglio" e' risolto?

Per il nuovo quesito, la spiegazione dell' errore si trovera' solo indagando sul file puntato dal "For Each" al momento dell' errore. Puoi raccogliere questo indizio aggiungendo questa riga nel tuo codice:
Codice: Seleziona tutto
For Each cartella In Application.Workbooks    'Esistente
Debug.Print cartella.Name                            'AGGIUNGERE
cartella.Save                                         'Esistente
Al momento dell' errore, mentre sei in Debug, premi Contr-g e vedi quale e' l' ultimo file elencato.

Personalmente pero' trovo criticabile che la macro salvi qualsiasi file che trova aperto, e non si limiti a salvare i file che lei stessa ha aperto; e, sempre "personalmente" ti diffido dall' abilitare la riga Application.Quit. A meno che tutto girera' sempre e solo su un tuo pc e non di altri utenti.

Ciao
Avatar utente
Anthony47
Moderatore
 
Post: 19220
Iscritto il: 21/03/06 16:03
Località: Ivrea

Re: [Excel2013] Conversione dati da textbox a foglio

Postdi fastbike73 » 13/12/14 08:55

Anthony47 ha scritto:Il problema della "Conversione dati da textbox a foglio" e' risolto?

Per il nuovo quesito, la spiegazione dell' errore si trovera' solo indagando sul file puntato dal "For Each" al momento dell' errore. Puoi raccogliere questo indizio aggiungendo questa riga nel tuo codice:
Codice: Seleziona tutto
For Each cartella In Application.Workbooks    'Esistente
Debug.Print cartella.Name                            'AGGIUNGERE
cartella.Save                                         'Esistente
Al momento dell' errore, mentre sei in Debug, premi Contr-g e vedi quale e' l' ultimo file elencato.

Personalmente pero' trovo criticabile che la macro salvi qualsiasi file che trova aperto, e non si limiti a salvare i file che lei stessa ha aperto; e, sempre "personalmente" ti diffido dall' abilitare la riga Application.Quit. A meno che tutto girera' sempre e solo su un tuo pc e non di altri utenti.

Ciao


Buongiorno Anthony, ti ringrazio per i suggerimenti. Dunque, l'Application quit non verrà mai attivato, come tu stesso avrai capito il codice non è frutto delle mie conoscenze ma di una spasmodica ricerca in internet. Il problema della conversione ancora non è risolto, anche dopo le modifiche suggerite. Adesso, faccio la prova che mi hai detto così vediamo cosa esce.... ti faccio sapere...
fastbike73
Win 10 & Office365
Filemaker Pro v. 13
fastbike73
Utente Senior
 
Post: 256
Iscritto il: 23/04/14 10:54

Re: [Excel2013] Conversione dati da textbox a foglio

Postdi Anthony47 » 13/12/14 12:13

Se il problema della conversione dati non e' ancora risolto dovresti fare un esempio: contenuto del textbox, codice vba per la conversione e il caricamento nella cella, eventuale codice per la formattazione cella, contenuto finale errato della cella, contenuto che invece avresti voluto ottenere.

Ciao
Avatar utente
Anthony47
Moderatore
 
Post: 19220
Iscritto il: 21/03/06 16:03
Località: Ivrea

Re: [Excel2013] Conversione dati da textbox a foglio

Postdi fastbike73 » 17/12/14 09:42

Buongiorno Anthony. Buone notizie, finalmente sono riuscito a sistemare tutte le conversione di dati da textbox a foglio. Adesso funziona tutto alla perfezione. Il successivo step richiede però l'apertura di un nuovo 3d.... ti ringrazio per tutto quello che hai fatto fino ad ora!!!! E grazie al forum di esistere!!
fastbike73
Win 10 & Office365
Filemaker Pro v. 13
fastbike73
Utente Senior
 
Post: 256
Iscritto il: 23/04/14 10:54


Torna a Applicazioni Office Windows


Topic correlati a "[Excel2013] Conversione dati da textbox a foglio":


Chi c’è in linea

Visitano il forum: Nessuno e 28 ospiti

cron