| | Post: 143 | Registrato il: 09/04/2015
| Età: 45 | Utente Junior | 2013 | | OFFLINE | |
|
31/07/2018 10:26 | |
Ciao a tutti,
ho un problemino stupidissimo. Ho inserito un pulsante, provato sia come modulo che come ActiveX, e nel momento in cui scrivo il codice per aprirlo mi restituisce error 9:
Payment.Show
Vi allego un piccolo video che mostra il problema, non ho idea di come aggirare questo fatto, anche perchè nella stessa maniera apro altri 5 form diversi.
In attesa di un Vs aiuto, grazie mille
|
|
| | Post: 3.835 | Registrato il: 21/06/2013
| Città: NAPOLI | Età: 70 | Utente Master | Excel 365 | | OFFLINE |
|
31/07/2018 11:17 | |
Ciao Shady
Più che un video (che al momento non posso vedere) avresti dovuto allegare il file.
Comunque da quello che dici sembrebbe che non esista un form denominato Payment.
Alfredo |
| | Post: 143 | Registrato il: 09/04/2015
| Età: 45 | Utente Junior | 2013 | | OFFLINE | |
|
31/07/2018 11:31 | |
appunto è quello che sembra anche a me, ma infatti ho pubblicato il video proprio per mostrare che il form esiste e si chiama proprio così.
Ad ogni modo riallego il file excel, file senza dati solo per verificare questo problema, grazie mille |
| | Post: 3.836 | Registrato il: 21/06/2013
| Città: NAPOLI | Età: 70 | Utente Master | Excel 365 | | OFFLINE |
|
31/07/2018 11:40 | |
Purtroppo non ho al momento un pc.
Ma qual'è la riga evidenziata dal Debug? Payment.Show?
L'errore di run-time 9 Indice non incluso nell'intervallo sta ad indicare che non viene trovato un qualcosa che invece ci dovrebbe essere.
Alfredo |
| | Post: 144 | Registrato il: 09/04/2015
| Età: 45 | Utente Junior | 2013 | | OFFLINE | |
|
31/07/2018 12:03 | |
esattamente la riga di debug è quella, Payment.Show...
Ma come si risolve? ho provato ad eliminare e ricreare il pulsante sia come modulo che come activex ma niente... |
| | Post: 649 | Registrato il: 02/08/2015
| Utente Senior | Excel 2013 | | OFFLINE |
|
31/07/2018 12:11 | |
Ciao,
l'errore non è nel nome della UserForm ma nel codice di inizializzazione della UserForm (l'avresti notato controllando step by step con il tasto F8 quando ti manda in debug).
Private Sub UserForm_Initialize()
Dim sh, sh1 As Worksheet
Application.ScreenUpdating = False
Application.EnableEvents = False
Set sh = Worksheets("ELENCO")
Set sh1 = Worksheets("PAYMENT")
'ETC....
End Sub
come vedi stai settando la variabile Sh1 con un foglio che nel file non esiste ---> Worksheets("PAYMENT")
Ciao
Tore
"Sono le persone che nessuno immagina che possano fare certe cose, quelle che fanno cose che nessuno può immaginare." |
| | Post: 3.837 | Registrato il: 21/06/2013
| Città: NAPOLI | Età: 70 | Utente Master | Excel 365 | | OFFLINE |
|
31/07/2018 12:18 | |
|
| | Post: 145 | Registrato il: 09/04/2015
| Età: 45 | Utente Junior | 2013 | | OFFLINE | |
|
31/07/2018 13:52 | |
Grazie mille |
| | Post: 3.838 | Registrato il: 21/06/2013
| Città: NAPOLI | Età: 70 | Utente Master | Excel 365 | | OFFLINE |
|
31/07/2018 14:01 | |
L'errore di runt-time 9 ti dice che nel (quasi) 100% dei casi c'è il nome di un foglio che non esiste. [Modificato da alfrimpa 31/07/2018 14:02]
Alfredo |
| | Post: 3.620 | Registrato il: 28/06/2011
| Città: AGORDO | Età: 70 | Utente Master | 2013 | | OFFLINE | |
|
31/07/2018 14:33 | |
Presumo che nel spostare non hai allegato il foglio PAYMENT
Dato che salti da un codice all'altro suggerisco di scrivere le variabili... EX Public x As Long, Public sh As Worksheet ecc ecc
Un codice orrendo e desidero ricordare che certi passaggi li puoi fare solo da un modulo. Se ho capito bene, EX
vb Private Sub UserForm_Initialize()
Dim x As Long, ULTIMARIGA As Long,sh1 As Worksheet
Set sh1 = Worksheets("PAYMENT")
ULTIMARIGA = sh1.Cells(Rows.Count, 20).End(xlUp).Row
For x = 2 To ULTIMARIGA 'Step 1
sh1.Cells(x, 20).Font.ColorIndex = 1
sh1.Cells(x, 20).Interior.ColorIndex = False
comboIMP1.AddItem Cells(x, 20).Value 'UserPayment.
Next
Set sh1 = Nothing
End Sub
In un Modulo e nota le modifiche
vb Sub Payments_Click()
Dim sh As Worksheet, sh1 As Worksheet 'leggi
Dim URG As Long, ULTIMARIGA As Long 'leggi
Application.ScreenUpdating = False
Application.EnableEvents = False
Set sh = Worksheets("ELENCO")
Set sh1 = Worksheets("PAYMENT")
'FORMAT INTESTAZIONE PAGINA
'sh1.Activate
For Each Ctrl In sh1.Shapes 'ActiveSheet.Shapes
Ctrl.Visible = True
Next
'Range("A3").Select
'ActiveWindow.FreezePanes = False 'cosa serve?
sh1.Cells.Clear 'presumo desideri cancellare foglio PAYMENT
URG = sh.Cells(Rows.Count, 1).End(xlUp).Row
'sh.Activate
sh.Range(sh.Cells(1, 1), sh.Cells(3, 14)).Copy 'Select
'Selection.Copy
'sh1.Activate
sh1.Range("A1").PasteSpecial 'Select
'ActiveSheet.Paste
'sh.Activate
sh.Range(sh.Cells(1, 22), sh.Cells(3, 25)).Copy 'altra area???
'Selection.Copy
'sh1.Activate
sh1.Range("Q1").PasteSpecial 'Select
'ActiveSheet.Paste
'Rows(2).Select
sh1.Rows(2).Delete Shift:=xlUp
'Columns("I:I").Select
'Columns("I:I").Delete SHIFT:=xlToLeft
sh1.Rows("1:1").RowHeight = 50
sh1.Rows("2:2").RowHeight = 23.25
'Range("A3").Select
'ActiveWindow.FreezePanes = True '???
sh1.Range("N2").Value = "ETA"
'CREO ELENCO comboIMP
'sh.Activate
URG = sh.Cells(Rows.Count, 1).End(xlUp).Row
'non dovrebbe essere T2?
sh.Range(sh.Cells(3, 4), sh.Cells(URG, 4)).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=sh1.Range("T1"), Unique:=True
'sh1.Activate
'da qui in poi non capisco bene dove lavori, presumo sia solo su PAYMENT
ULTIMARIGA = sh1.Cells(Rows.Count, 20).End(xlUp).Row
'ORDINAMENTO ALFABETICO
Set rng = sh1.Range(sh1.Cells(2, 20), sh1.Cells(ULTIMARIGA, 20))
'rng.Select
sh1.Sort.SortFields.Clear
sh1.Sort.SortFields.Add Key:=Range("T2"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With sh1.Sort
.SetRange rng ' qui dovrei ridire
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
If sh1.Cells(2, 20).Value = "" Then sh1.Cells(2, 20).Delete Shift:=xlUp
Application.ScreenUpdating = True
Application.EnableEvents = True
Set sh1 = Nothing
Set sh = Nothing
Set rng = Nothing
Payment.Show
End Sub [Modificato da raffaele1953 01/08/2018 14:36] Excel 2013 |
|
|