excel vba Errore Run Time 2147352571(80020005) impossibile impostare la Proprieta' Value (#N/D)

Anonimo
2018-06-20T09:04:23+00:00

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

Microsoft 365 e Office | Excel | Per la casa | Windows

Domanda bloccata. Questa domanda è stata eseguita dalla community del supporto tecnico Microsoft. È possibile votare se è utile, ma non è possibile aggiungere commenti o risposte o seguire la domanda.

0 commenti Nessun commento
Risposta accettata dall'autore della domanda
Anonimo
2018-06-20T10:23:07+00:00

Ciao Claudio,

Non riesco a  eliminare l'errore che ho riportato in Oggetto .

[...]

Prova.tbNrVinte = Sheets("Simulatore").Cells(1, i).Value 

[...]

Prova:

   Prova.tbNrVinte**.Value** = Sheets("Simulatore").Cells(1, i).Text

Altrimenti, non volendo vedere il valore #N/D nel controllo tbNrVinte, prova qualcosa del genere:

    With Sheets("Simulatore").Cells(1, i)

        If Not IsError(.Value) Then

            Me.tbNrVinte.Value = .Value

        Else

            Me..tbNrVinte.Value = vbNullString

                Call MsgBox( _

                     Prompt:="la cella " & .Address(0, 0, , 1) _

                     & " restituisce il valore " & .Text, _

                     Buttons:=vbInformation, _

                     Title:="REPORT")

        End If

    End With

===

Regards,

Norman

La risposta è stata utile?

1 persona ha trovato utile questa risposta.
0 commenti Nessun commento

2 risposte aggiuntive

Ordina per: Più utili
  1. Anonimo
    2018-06-21T11:43:48+00:00

    Ciao Claudio,

    GRAZIE   GRAZIE 

    Prego!

    Adesso  finalmente posso passare alla parte per me piu complicata , la gestione dei cicli   e delle  variabili ...

    Buon lavoro!

    In caso di bisogno, siamo sempre qui.

    ===

    Regards,

    Norman

    La risposta è stata utile?

    0 commenti Nessun commento
  2. Anonimo
    2018-06-20T12:13:24+00:00

    Buon giorno  Norman

    GRAZIE   GRAZIE

    Adesso  finalmente posso passare alla parte per me piu complicata , la gestione dei cicli   e delle  variabili ...

    Grazie di nuovo          Claudio P

    La risposta è stata utile?

    0 commenti Nessun commento