Ottieni l'articolo in Collezione VBA per nome

Ahoy hoy,

Sto provando a fare roba a un object personalizzato in una raccolta personalizzata facendo riferimento alla properties; di nome in VBA Excel. Lo giuro che ha funzionato prima (o alless non ha gettato un errore) e ora il suo cappotto. Ho una errata invalid call or argument errore di invalid call or argument quando cerco di Get qualcosa da una string. Ringraziamenti in anticipo per anche leggere questo anche, qualsiasi aiuto è apprezzato. <\ Modifica>

  • Raccolta a combobox
  • Come memorizzare le posizioni delle celle (fila, colonna) in Java?
  • Raccolta di oggetti personalizzati
  • Drools - Uso di "da" nella tabella delle decisioni
  • Incollare gli elementi della gamma nelle colonne VBA
  • Ecco la collezione:

     Option Explicit Private DRAFields As New Collection Sub Add(Name As String, Optional colNbr As Long, Optional Exists As Boolean) Dim fld As New DRAFld fld.colNbr = colNbr fld.Name = Name fld.Exists = Exists DRAFields.Add fld End Sub Property Get Item(NameOrNumber As Variant) Set Item = DRAFields(NameOrNumber) '<------- Error here End Property Private DRAFields come nuova collezione Option Explicit Private DRAFields As New Collection Sub Add(Name As String, Optional colNbr As Long, Optional Exists As Boolean) Dim fld As New DRAFld fld.colNbr = colNbr fld.Name = Name fld.Exists = Exists DRAFields.Add fld End Sub Property Get Item(NameOrNumber As Variant) Set Item = DRAFields(NameOrNumber) '<------- Error here End Property Sub Add (nome come string, opzionale colNbr come lungo, facoltativo esiste come boolean) Option Explicit Private DRAFields As New Collection Sub Add(Name As String, Optional colNbr As Long, Optional Exists As Boolean) Dim fld As New DRAFld fld.colNbr = colNbr fld.Name = Name fld.Exists = Exists DRAFields.Add fld End Sub Property Get Item(NameOrNumber As Variant) Set Item = DRAFields(NameOrNumber) '<------- Error here End Property Dim fld come nuovo DRAFld Option Explicit Private DRAFields As New Collection Sub Add(Name As String, Optional colNbr As Long, Optional Exists As Boolean) Dim fld As New DRAFld fld.colNbr = colNbr fld.Name = Name fld.Exists = Exists DRAFields.Add fld End Sub Property Get Item(NameOrNumber As Variant) Set Item = DRAFields(NameOrNumber) '<------- Error here End Property fld.colNbr = colNbr Option Explicit Private DRAFields As New Collection Sub Add(Name As String, Optional colNbr As Long, Optional Exists As Boolean) Dim fld As New DRAFld fld.colNbr = colNbr fld.Name = Name fld.Exists = Exists DRAFields.Add fld End Sub Property Get Item(NameOrNumber As Variant) Set Item = DRAFields(NameOrNumber) '<------- Error here End Property fld.Name = Nome Option Explicit Private DRAFields As New Collection Sub Add(Name As String, Optional colNbr As Long, Optional Exists As Boolean) Dim fld As New DRAFld fld.colNbr = colNbr fld.Name = Name fld.Exists = Exists DRAFields.Add fld End Sub Property Get Item(NameOrNumber As Variant) Set Item = DRAFields(NameOrNumber) '<------- Error here End Property fld.Exists = Esiste Option Explicit Private DRAFields As New Collection Sub Add(Name As String, Optional colNbr As Long, Optional Exists As Boolean) Dim fld As New DRAFld fld.colNbr = colNbr fld.Name = Name fld.Exists = Exists DRAFields.Add fld End Sub Property Get Item(NameOrNumber As Variant) Set Item = DRAFields(NameOrNumber) '<------- Error here End Property DRAFields.Add fld Option Explicit Private DRAFields As New Collection Sub Add(Name As String, Optional colNbr As Long, Optional Exists As Boolean) Dim fld As New DRAFld fld.colNbr = colNbr fld.Name = Name fld.Exists = Exists DRAFields.Add fld End Sub Property Get Item(NameOrNumber As Variant) Set Item = DRAFields(NameOrNumber) '<------- Error here End Property Proprietà Get Item (NomeOrNumber come variante) Option Explicit Private DRAFields As New Collection Sub Add(Name As String, Optional colNbr As Long, Optional Exists As Boolean) Dim fld As New DRAFld fld.colNbr = colNbr fld.Name = Name fld.Exists = Exists DRAFields.Add fld End Sub Property Get Item(NameOrNumber As Variant) Set Item = DRAFields(NameOrNumber) '<------- Error here End Property Imposta l'elemento = DRAFields (NameOrNumber) '<------- Errore qui Option Explicit Private DRAFields As New Collection Sub Add(Name As String, Optional colNbr As Long, Optional Exists As Boolean) Dim fld As New DRAFld fld.colNbr = colNbr fld.Name = Name fld.Exists = Exists DRAFields.Add fld End Sub Property Get Item(NameOrNumber As Variant) Set Item = DRAFields(NameOrNumber) '<------- Error here End Property 

    Le collezioni hanno elementi aggiunti passando una serie di nomi a una function e la raccolta viene restituita senza emettere. Posso ripetere l'uso utilizzando la chiave. Ma l'errore si verifica se si ottiene come tale: Debug.Print myFlds.Item("Customer").colNbr

    E la class object nel caso in cui:

     Option Explicit Private clmNbrPvt As Long Private namePvt As String Private existsPvt As Boolean Public Property Get colNbr() As Long colNbr = clmNbrPvt End Property Public Property Let colNbr(lngParam As Long) clmNbrPvt = lngParam End Property Public Property Get Name() As String Name = namePvt End Property Public Property Let Name(strParam As String) namePvt = strParam End Property Public Property Get Exists() As Boolean Exists = existsPvt End Property Public Property Let Exists(booParam As Boolean) existsPvt = booParam End Property Privato clmNbrPvt As Long Option Explicit Private clmNbrPvt As Long Private namePvt As String Private existsPvt As Boolean Public Property Get colNbr() As Long colNbr = clmNbrPvt End Property Public Property Let colNbr(lngParam As Long) clmNbrPvt = lngParam End Property Public Property Get Name() As String Name = namePvt End Property Public Property Let Name(strParam As String) namePvt = strParam End Property Public Property Get Exists() As Boolean Exists = existsPvt End Property Public Property Let Exists(booParam As Boolean) existsPvt = booParam End Property Nome privatoPvt As String Option Explicit Private clmNbrPvt As Long Private namePvt As String Private existsPvt As Boolean Public Property Get colNbr() As Long colNbr = clmNbrPvt End Property Public Property Let colNbr(lngParam As Long) clmNbrPvt = lngParam End Property Public Property Get Name() As String Name = namePvt End Property Public Property Let Name(strParam As String) namePvt = strParam End Property Public Property Get Exists() As Boolean Exists = existsPvt End Property Public Property Let Exists(booParam As Boolean) existsPvt = booParam End Property Private existsPvt Come boolean Option Explicit Private clmNbrPvt As Long Private namePvt As String Private existsPvt As Boolean Public Property Get colNbr() As Long colNbr = clmNbrPvt End Property Public Property Let colNbr(lngParam As Long) clmNbrPvt = lngParam End Property Public Property Get Name() As String Name = namePvt End Property Public Property Let Name(strParam As String) namePvt = strParam End Property Public Property Get Exists() As Boolean Exists = existsPvt End Property Public Property Let Exists(booParam As Boolean) existsPvt = booParam End Property Proprietà pubblica Get colNbr () As Long Option Explicit Private clmNbrPvt As Long Private namePvt As String Private existsPvt As Boolean Public Property Get colNbr() As Long colNbr = clmNbrPvt End Property Public Property Let colNbr(lngParam As Long) clmNbrPvt = lngParam End Property Public Property Get Name() As String Name = namePvt End Property Public Property Let Name(strParam As String) namePvt = strParam End Property Public Property Get Exists() As Boolean Exists = existsPvt End Property Public Property Let Exists(booParam As Boolean) existsPvt = booParam End Property colNbr = clmNbrPvt Option Explicit Private clmNbrPvt As Long Private namePvt As String Private existsPvt As Boolean Public Property Get colNbr() As Long colNbr = clmNbrPvt End Property Public Property Let colNbr(lngParam As Long) clmNbrPvt = lngParam End Property Public Property Get Name() As String Name = namePvt End Property Public Property Let Name(strParam As String) namePvt = strParam End Property Public Property Get Exists() As Boolean Exists = existsPvt End Property Public Property Let Exists(booParam As Boolean) existsPvt = booParam End Property Proprietà pubblica Lasciate colNbr (lngParam As Long) Option Explicit Private clmNbrPvt As Long Private namePvt As String Private existsPvt As Boolean Public Property Get colNbr() As Long colNbr = clmNbrPvt End Property Public Property Let colNbr(lngParam As Long) clmNbrPvt = lngParam End Property Public Property Get Name() As String Name = namePvt End Property Public Property Let Name(strParam As String) namePvt = strParam End Property Public Property Get Exists() As Boolean Exists = existsPvt End Property Public Property Let Exists(booParam As Boolean) existsPvt = booParam End Property clmNbrPvt = lngParam Option Explicit Private clmNbrPvt As Long Private namePvt As String Private existsPvt As Boolean Public Property Get colNbr() As Long colNbr = clmNbrPvt End Property Public Property Let colNbr(lngParam As Long) clmNbrPvt = lngParam End Property Public Property Get Name() As String Name = namePvt End Property Public Property Let Name(strParam As String) namePvt = strParam End Property Public Property Get Exists() As Boolean Exists = existsPvt End Property Public Property Let Exists(booParam As Boolean) existsPvt = booParam End Property Proprietà pubblica Get Name () come string Option Explicit Private clmNbrPvt As Long Private namePvt As String Private existsPvt As Boolean Public Property Get colNbr() As Long colNbr = clmNbrPvt End Property Public Property Let colNbr(lngParam As Long) clmNbrPvt = lngParam End Property Public Property Get Name() As String Name = namePvt End Property Public Property Let Name(strParam As String) namePvt = strParam End Property Public Property Get Exists() As Boolean Exists = existsPvt End Property Public Property Let Exists(booParam As Boolean) existsPvt = booParam End Property Nome = nomePvt Option Explicit Private clmNbrPvt As Long Private namePvt As String Private existsPvt As Boolean Public Property Get colNbr() As Long colNbr = clmNbrPvt End Property Public Property Let colNbr(lngParam As Long) clmNbrPvt = lngParam End Property Public Property Get Name() As String Name = namePvt End Property Public Property Let Name(strParam As String) namePvt = strParam End Property Public Property Get Exists() As Boolean Exists = existsPvt End Property Public Property Let Exists(booParam As Boolean) existsPvt = booParam End Property Proprietà pubblica come nome (strParam As String) Option Explicit Private clmNbrPvt As Long Private namePvt As String Private existsPvt As Boolean Public Property Get colNbr() As Long colNbr = clmNbrPvt End Property Public Property Let colNbr(lngParam As Long) clmNbrPvt = lngParam End Property Public Property Get Name() As String Name = namePvt End Property Public Property Let Name(strParam As String) namePvt = strParam End Property Public Property Get Exists() As Boolean Exists = existsPvt End Property Public Property Let Exists(booParam As Boolean) existsPvt = booParam End Property namePvt = strParam Option Explicit Private clmNbrPvt As Long Private namePvt As String Private existsPvt As Boolean Public Property Get colNbr() As Long colNbr = clmNbrPvt End Property Public Property Let colNbr(lngParam As Long) clmNbrPvt = lngParam End Property Public Property Get Name() As String Name = namePvt End Property Public Property Let Name(strParam As String) namePvt = strParam End Property Public Property Get Exists() As Boolean Exists = existsPvt End Property Public Property Let Exists(booParam As Boolean) existsPvt = booParam End Property Proprietà pubblica ottiene () come boolean Option Explicit Private clmNbrPvt As Long Private namePvt As String Private existsPvt As Boolean Public Property Get colNbr() As Long colNbr = clmNbrPvt End Property Public Property Let colNbr(lngParam As Long) clmNbrPvt = lngParam End Property Public Property Get Name() As String Name = namePvt End Property Public Property Let Name(strParam As String) namePvt = strParam End Property Public Property Get Exists() As Boolean Exists = existsPvt End Property Public Property Let Exists(booParam As Boolean) existsPvt = booParam End Property Exists = existsPvt Option Explicit Private clmNbrPvt As Long Private namePvt As String Private existsPvt As Boolean Public Property Get colNbr() As Long colNbr = clmNbrPvt End Property Public Property Let colNbr(lngParam As Long) clmNbrPvt = lngParam End Property Public Property Get Name() As String Name = namePvt End Property Public Property Let Name(strParam As String) namePvt = strParam End Property Public Property Get Exists() As Boolean Exists = existsPvt End Property Public Property Let Exists(booParam As Boolean) existsPvt = booParam End Property Proprietà pubblica esiste (booParam come boolean) Option Explicit Private clmNbrPvt As Long Private namePvt As String Private existsPvt As Boolean Public Property Get colNbr() As Long colNbr = clmNbrPvt End Property Public Property Let colNbr(lngParam As Long) clmNbrPvt = lngParam End Property Public Property Get Name() As String Name = namePvt End Property Public Property Let Name(strParam As String) namePvt = strParam End Property Public Property Get Exists() As Boolean Exists = existsPvt End Property Public Property Let Exists(booParam As Boolean) existsPvt = booParam End Property existsPvt = booParam Option Explicit Private clmNbrPvt As Long Private namePvt As String Private existsPvt As Boolean Public Property Get colNbr() As Long colNbr = clmNbrPvt End Property Public Property Let colNbr(lngParam As Long) clmNbrPvt = lngParam End Property Public Property Get Name() As String Name = namePvt End Property Public Property Let Name(strParam As String) namePvt = strParam End Property Public Property Get Exists() As Boolean Exists = existsPvt End Property Public Property Let Exists(booParam As Boolean) existsPvt = booParam End Property 

    E perché non quella function:

     Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function Funzione validateAndBuildDRAFields (ByRef arrReqFields () come string, _ Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function inputSheet come foglio di lavoro, _ Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function VBAModule opzionale come string) come clsDRAFields Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function Dim Dimensione: lEndCol = Standard.zGetLastColumn (inputSheet, 1) Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function Dim x As Long Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function Dim intExit As Long Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function Dim myDRAFields come nuovo clsDRAFields Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function Impostare validateAndBuildDRAFields = myDRAFields Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function 'Costruisce gli elementi di myDRAFields da arrReqFields Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function Per i = LBound (arrReqFields) A UBound (arrReqFields) Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function myDRAFields.Add arrReqFields (i) Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function 'controlla se i campi necessari esistono sul foglio di input Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function 'se trovato quindi impostare il numero di colonna e esiste = true Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function Per i = 1 a myDRAFields.Count Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function Per x = 1 a lEndCol Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function Se inputSheet.Cells (1, x) = myDRAFields.Item (i). Nome Poi Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function myDRAFields.Item (i) .colNbr = x Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function myDRAFields.Item (i) .Exists = Vero Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function intExit = intExit + 1 Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function Se intExit = UBound (arrReqFields) + 1, quindi esci per Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function 'dice all'utente se ci sono campi mancanti e termina se true Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function Se (non intExit = UBound (arrReqFields) + 1) O _ Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function intExit = 0 Poi Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function Per i = 1 a myDRAFields.Count Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function Se myDRAFields.Item (i) .Exists = Falso allora Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function Call Standard.TheEndWithError ("Non ho trovato il" & myDRAFields.Item (i) .Name & _ Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function "nel file. Aggiungi" & myDRAFields.Item (i) .Name & _ Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function "al tuo layout DRA". False, VBAModule) Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function Impostare myDRAFields = Niente Function validateAndBuildDRAFields(ByRef arrReqFields() As String, _ inputSheet As Worksheet, _ Optional VBAModule As String) As clsDRAFields Dim lEndCol As Long: lEndCol = Standard.zGetLastColumn(inputSheet, 1) Dim i As Long Dim x As Long Dim intExit As Long Dim myDRAFields As New clsDRAFields Set validateAndBuildDRAFields = myDRAFields 'Builds myDRAFields items from arrReqFields For i = LBound(arrReqFields) To UBound(arrReqFields) myDRAFields.Add arrReqFields(i) Next i 'checks if required fields exist on input sheet 'if found then sets column number and exists = true For i = 1 To myDRAFields.Count For x = 1 To lEndCol If inputSheet.Cells(1, x) = myDRAFields.Item(i).Name Then myDRAFields.Item(i).colNbr = x myDRAFields.Item(i).Exists = True intExit = intExit + 1 Exit For End If Next x If intExit = UBound(arrReqFields) + 1 Then Exit For Next i ' tells user if there are any missing fields and ends if true If (Not intExit = UBound(arrReqFields) + 1) Or _ intExit = 0 Then For i = 1 To myDRAFields.Count If myDRAFields.Item(i).Exists = False Then Call Standard.TheEndWithError("I couldn't find the " & myDRAFields.Item(i).Name & _ " column in your file. Please add " & myDRAFields.Item(i).Name & _ " to your DRA Layout.", False, VBAModule) End If Next i Set myDRAFields = Nothing Standard.TheEnd End If End Function 

  • leggere / scrivere un semplice file excel usando c #
  • Come eseguire datatable contro la stored procedure per aggiornare il database?
  • Come caricare un Excel Addin utilizzando Interop
  • Filtro avanzato in Excel
  • Programmaticamente assegna una macro a un combobox in excel
  • Lo script XML di componente aggiuntivo continua a scomparire dopo il salvataggio
  • One Solution collect form web for “Ottieni l'articolo in Collezione VBA per nome”

    Per accedere a un elemento di raccolta per la chiave, è necessario fornire una chiave quando si aggiunge l'elemento alla raccolta. La chiave è facoltativa. Quando si accede a un elemento di raccolta con una string, il metodo dell'articolo assume che si desidera corrispondere alla chiave. Quando si utilizza un numero integer, si suppone che si desidera l'indice di posizione.

    Quindi, cambiare la row nel metodo Aggiungi a

     DRAFields.Add fld, fld.Name 

    e potrai accedere agli elementi dalla properties; Name.

    Microsoft Office Excel Spreadsheet è il miglior software di Office, Excel VBA e formule Excel rendono il foglio di calcolo più veloce.