Con il codice sotto riportato vado a registrare i dati della singola Fattura, scelta preventivamente dalla combobox1, nell'Archivio Fatture dello stesso file. Quindi, scegliendo dalla combobox1 la Fattura il codice compie il suo dovere.
Il problema è questo: avrei bisogno che i dati della fattura, scelta dalla combobo1, vengano registrati su un file esterno chiamato "Fatturazione" sul foglio chiamato "Archivio Generale".
Ho fatto tante prove ma non riesco a venirne fuori. Sono nel panico; o non registra niente, oppure, va in crash.
Grazie
- Codice: Seleziona tutto
' Registra singola fattura scelta dalla combobox1 in Archivio Fatture in questo file
If ComboBox1 = "" Or ComboBox1 = "" Then
MsgBox "Scrivere il Codice Cliente da Archiviare !", vbExclamation, "Inserisci il Cliente..."
ComboBox1.SetFocus
Exit Sub
End If
If (ComboBox1.ListIndex <> -1) Then
TxtOption = ComboBox1.List(ComboBox1.ListIndex)
Else
MsgBox ("La Fattura scelta non Esiste!")
Exit Sub
End If
Dim msg, Style, title, response, MyString
msg = "Vuoi Registrare in Archivio la singola Fattura ? "
Style = vbYesNo + vbExclamation + vbDefaultButton2
title = "ATTENZIONE !"
response = MsgBox(msg, Style, title)
If response = vbYes Then
MyString = "Yes"
Application.ScreenUpdating = False ' disattiva lo schermo
Dim irow As Integer
irow = 3 ' inizia a scrivere dalla riga 3
While Sheets("Archivio Fatture").Cells(irow, 1) <> ""
irow = irow + 1
Wend
Sheets("Archivio Fatture").Cells(irow, 1) = [C13]
Sheets("Archivio Fatture").Cells(irow, 2) = [f6]
Sheets("Archivio Fatture").Cells(irow, 3) = [f7]
Sheets("Archivio Fatture").Cells(irow, 4) = [f8]
Sheets("Archivio Fatture").Cells(irow, 5) = [g8]
Sheets("Archivio Fatture").Cells(irow, 6) = [g9]
Sheets("Archivio Fatture").Cells(irow, 7) = [g10]
Sheets("Archivio Fatture").Cells(irow, 8) = [i3]
Sheets("Archivio Fatture").Cells(irow, 9) = [g3]
Sheets("Archivio Fatture").Cells(irow, 10) = [c15]
Sheets("Archivio Fatture").Cells(irow, 11) = [e15]
Sheets("Archivio Fatture").Cells(irow, 12) = [b18]
Sheets("Archivio Fatture").Cells(irow, 13) = [b20]
Sheets("Archivio Fatture").Cells(irow, 14) = [b21]
Sheets("Archivio Fatture").Cells(irow, 15) = [c21]
Sheets("Archivio Fatture").Cells(irow, 16) = [e41]
Sheets("Archivio Fatture").Cells(irow, 17) = [g41]
Sheets("Archivio Fatture").Cells(irow, 18) = [i41]
Sheets("Archivio Fatture").Cells(irow, 19) = [h40]
Sheets("Archivio Fatture").Cells(irow, 20) = [b22]
Sheets("Archivio Fatture").Cells(irow, 21) = [b24]
Sheets("Archivio Fatture").Cells(irow, 22) = [b25]
Sheets("Archivio Fatture").Cells(irow, 23) = [c25]
Sheets("Archivio Fatture").Cells(irow, 24) = [b26]
Sheets("Archivio Fatture").Cells(irow, 25) = [b28]
Sheets("Archivio Fatture").Cells(irow, 26) = [b29]
Sheets("Archivio Fatture").Cells(irow, 27) = [c29]
Sheets("Archivio Fatture").Cells(irow, 28) = [b30]
Sheets("Archivio Fatture").Cells(irow, 29) = [b32]
Sheets("Archivio Fatture").Cells(irow, 30) = [33]
Sheets("Archivio Fatture").Cells(irow, 31) = [c33]
Sheets("Archivio Fatture").Cells(irow, 32) = [b34]
Sheets("Archivio Fatture").Cells(irow, 33) = [b36]
Sheets("Archivio Fatture").Cells(irow, 34) = [b37]
Sheets("Archivio Fatture").Cells(irow, 35) = [c37]
Sheets("Archivio Fatture").Cells(irow, 36) = [b38]
Sheets("Archivio Fatture").Cells(irow, 37) = [c14]
Application.ScreenUpdating = True ' attiviamo lo schermo
MsgBox "La Fattura - " & ComboBox1.Value & " - è stata Registrata con successo!", vbInformation, "Fattura Registrata..."
CommandButton40.BackColor = 65535 '<--- Il pulsante si colora di giallo indicandomi così che è stato usato
Else
MyString = "No"
End If