Buon Giorno a tutti
Non riesco a eliminare l'errore che ho riportato in Oggetto .
L'inserimento dei dati e' il seguente
1 Inserimento Squadre
2 Assegnazione alle Squadre dei Giocatori (selezionando la squadra di interesse ..)
Se ad una squadra che e' stata inserita , non e' ancora stato assegnato nessun Giocatore , questa e' comunque nell'elenco delle squadre (ListBox1)
Ma se vado per errore a selezionarla , ... si verifica l'errore
La sequenza e' la seguente
ListBox1.Click (seleziono squadra )
lbGioc Carica l'elenco dei giocatori di questa squadra
Prova.tbGiocate Carica Partite Giocate (questo crea errore perche' la cella da cui prende il valore riporta #N/D )
Prova.tbNrVinte Carica il Nr di Partite Vinte IDEM
Prova.tbDaGioc IDEM
Ringrazio per qualsiasi suggerimento Claudio P
Questo il Codice Evidenziata in Giallo la riga di errore ( la nr 90 )
Private Sub ListBox1_Click()
Dim i As Long
Dim Rng As Range
Dim sCol As String
Dim sTesto As String
Dim elemento As String
Dim p As String
Dim posiz As String
Dim wk1 As Workbook
Dim sh1 As Worksheet
Dim sh2 As Worksheet
Set wk1 = ThisWorkbook
Set sh1 = wk1.Worksheets("Output")
Set sh2 = wk1.Worksheets("Simulatore")
10
posiz = (ListBox1.ListIndex + 0)
i = 1
If lbGioc.ListCount >= 1 Then lbGioc.Clear
i = 2
Do Until Sheets("Output").Cells(i, 1).Value = ""
With Sheets("Output")
elemento = .Cells(i, posiz + 1)
End With
lbGioc.AddItem elemento
i = i + 1
Loop
20
i = 51
With sh1
Sheets("Output").Cells(2, i).Value = ""
End With
30
i = 51
With sh1
Sheets("Output").Cells(2, i).Value = Prova.ListBox1.Value
End With
40
i = 53
With sh1
Prova.tbColonna.Value = Sheets("Output").Cells(2, i).Text
End With
50
i = 55
With sh1
Prova.tbRiga.Value = Sheets("Output").Cells(2, i).Text
End With
60
Prova.tbSquadra.Value = Prova.ListBox1.Value
65
Prova.tbNuovoGioc.Value = Prova.ListBox1.Value
70
i = 5
With sh2
Sheets("Simulatore").Cells(1, i).Value = Prova.ListBox1.Value
End With
75
i = 16
With sh2
Sheets("Simulatore").Cells(1, i).Value = Prova.ListBox1.Value
End With
80
i = 24
With sh2
Prova.tbGiocate = Sheets("Simulatore").Cells(1, i).Value
End With
90
i = 19
With sh2
Prova.tbNrVinte = Sheets("Simulatore").Cells(1, i).Value
End With
100
i = 20
With sh2
Prova.tbDaGioc = Sheets("Simulatore").Cells(3, i).Text
End With
On Error GoTo XIT
Application.ScreenUpdating = False
XIT:
Application.ScreenUpdating = True
End Sub
La lbGioc carica l’elenco dei giocatori della squadra scelta in
ListBox1
Private Sub lbGioc_Click()
Dim i As Long
Dim Rng As Range
Dim sCol As String
Dim sTesto As String
Dim elemento As String
Dim p As String
Dim posiz As String
Dim sRiga As String
Dim wk1 As Workbook
Dim sh1 As Worksheet
Dim sh2 As Worksheet
Set wk1 = ThisWorkbook
Set sh1 = wk1.Worksheets("Output")
Set sh2 = wk1.Worksheets("Simulatore")
10
posiz = (lbGioc.ListIndex + 2)
20
With Me
tbRigaModGioc = posiz
End With
30
Prova.tbGioc.Value = Prova.lbGioc.Value
40
i = 61
With sh1
Sheets("Output").Cells(2, i).Value = Prova.tbGioc.Value
End With
60
i = 25
With sh2
Sheets("Simulatore").Cells(1, i).Value = Prova.tbGioc.Value
End With
80
i = 27
With sh2
Prova.tbRigaGioc1.Value = Sheets("Simulatore").Cells(1, i).Value
85
i = 29
With sh2
Prova.tbNrVinte.Value = Sheets("Simulatore").Cells(2, i).Value
End With
90
With Me
sRiga = tbRigaGioc1
End With
With sh2
.Range("C" & sRiga).Value = Prova.tbSquadra.Value
End With
End With
On Error GoTo XIT
Application.ScreenUpdating = False
XIT:
Application.ScreenUpdating = True
End Sub