Sviluppare funzionalita su Microsoft Office con VBA Macro con formula ricorrente

Login Registrati
Stai vedendo 4 articoli - dal 1 a 4 (di 4 totali)
  • Autore
    Articoli
  • #53984 Score: 0 | Risposta

    Frasubb
    Partecipante
      1 pt

      Ciao a tutti,

      avrei bisogno di inserire in questo codice

      Private Sub cmdInvia_Click()
      
          Dim contatore As String
          Dim rigaDebitore As Variant
          
      If cboRicerca <> "" Then
      MsgBox "Attenzione ! Record duplice", vbCritical, "Alert"
      Call cmdReset_Click
          Exit Sub
          
          ActiveSheet.Cells(2, 2) = TxtCliente.Text
          
      End If
      
      
      contatore = TxtContatore.Value
      
      If contatore = "" Then
      MsgBox "Inserire Contatore", vbExclamation, "Alert"
      TxtContatore.SetFocus
      Exit Sub
      
      ElseIf TxtCliente = "" Then
      MsgBox "Inserire nome debitore", vbExclamation, "Alert"
      TxtCliente.SetFocus
      Exit Sub
      
      ElseIf TxtMandato = "" Then
      MsgBox "Inserire codice mandato", vbExclamation, "Alert"
      TxtMandato.SetFocus
      Exit Sub
      
      
      ElseIf TxtDataOper = "" Then
      MsgBox "Inserire data operazione", vbExclamation, "Alert"
      TxtDataOper.SetFocus
      Exit Sub
      
      
      ElseIf TxtScadPag = "" Then
      MsgBox "Inserire scadenza di pagamento", vbExclamation, "Alert"
      TxtScadPag.SetFocus
      Exit Sub
      
      ElseIf TxtDebOrigin = "" Then
      MsgBox "Inserire debito originario", vbExclamation, "Alert"
      TxtDebOrigin.SetFocus
      Exit Sub
      
      ElseIf TxtAccord = "" Then
      MsgBox "Inserire importo accordato", vbExclamation, "Alert"
      TxtAccord.SetFocus
      Exit Sub
      
      ElseIf CboNumRate = "" Then
      MsgBox "Inserire il numero di rate accordate", vbExclamation, "Alert"
      CboNumRate.SetFocus
      Exit Sub
      
      ElseIf TxtDaPag = "" Then
      MsgBox "Inserire importo da pagare", vbExclamation, "Alert"
      TxtDaPag.SetFocus
      Exit Sub
      
      ElseIf ChkSiLib = False And ChkNoLib = False Then
      MsgBox "Inserire se ha diritto alla liberatoria ", vbExclamation, "Alert"
      ChkSiLib.SetFocus
      Exit Sub
      
      
      Else
      
      ActiveSheet.Range("A999999").End(xlUp).Offset(1).Select
      ActiveCell.Value = CDbl(TxtContatore)
      ActiveCell.Offset(0, 1).Value = TxtCliente
      ActiveCell.Offset(0, 2).Value = CDate(TxtDataOper)
      ActiveCell.Offset(0, 3).Value = TxtNote
      ActiveCell.Offset(0, 4).Value = TxtMandato
      ActiveCell.Offset(0, 5).Value = CDate(TxtScadPag)
      ActiveCell.Offset(0, 7).Value = CDbl(TxtDebOrigin)
      ActiveCell.Offset(0, 8).Value = CDbl(TxtAccord)
      ActiveCell.Offset(0, 9).Value = CDbl(CboNumRate)
      ActiveCell.Offset(0, 11).Value = CDbl(TxtDaPag)
      
          If ChkSiPag = True Then
          ActiveCell.Offset(0, 12).Value = "Si"
          Else
          ActiveCell.Offset(0, 12).Value = "No"
          End If
      
          If ChkSiContab = True Then
          ActiveCell.Offset(0, 14).Value = "Si"
          Else
          ActiveCell.Offset(0, 14).Value = "No"
          End If
          
          If ChkSiLib = True Then
          ActiveCell.Offset(0, 15).Value = "Si"
          Else
          ActiveCell.Offset(0, 15).Value = "No"
          End If
       
          If ChkSiRichLib = True Then
          ActiveCell.Offset(0, 16).Value = "Si"
          Else
          ActiveCell.Offset(0, 16).Value = "No"
          End If
          
          
      
      Call cmdReset_Click
      End If
      MsgBox "Inserimento effettuato con successo", vbInformation, "Avviso"
      
      Range("A2:R100").Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlNo
      
      On Error Resume Next
      rigaDebitore = Application.Match(CDbl(contatore), ActiveSheet.Range("A:A"), 0)
      On Error GoTo 0
      
      If Not IsError(rigaDebitore) Then
          Range("B" & rigaDebitore).Select
      End If
      
      
      End Sub

      la seguente formula: =SE(E2="";"";CERCA.VERT(E2;FEE!$A$2:$B$1859;2;0))

      affinché ogni volta che eseguo la macro, mi venga inserita insieme a tutti gli altri dati immessi tramite userform.

      Grazie in anticipo a chi mi vorrà aiutare, allego file esempio

      Allegati:
      You must be logged in to view attached files.
      #53986 Score: 0 | Risposta

      Raffaele53
      Partecipante
        22 pts

        Perché bisogna inserire un NUMERO in TxtContatore ???
        Quando poi verso la fine esiste >>> ActiveSheet.Range("A999999").End(xlUp).Offset(1).Select ???
        Serve capire in quale riga andrà la formula, per ex uso la variabile (Contatore)

        `'Contatore = TxtContatore.Value
        'If Contatore = "" Then
        'MsgBox "Inserire Contatore", vbExclamation, "Alert"
        'TxtContatore.SetFocus
        'Exit Sub
        '.....
        '.....
        '.....
        '.....
        '.....
        ActiveSheet.Range("A999999").End(xlUp).Offset(1).Select
        Contatore = ActiveCell.Offset(0, 0).Row
        ActiveCell.Offset(0, 0) = Contatore
        'ActiveCell.Value = CDbl(TxtContatore) 'non serve a nulla ???
        ActiveCell.Offset(0, 1).Value = TxtCliente
        ActiveCell.Offset(0, 2).Value = CDate(TxtDataOper)
        ActiveCell.Offset(0, 3).FormulaLocal = "=SE(E" & Contatore & "="""";"""";CERCA.VERT(E" & Contatore & ";FEE!$A$2:$B$1859;2;0))"`
        #54032 Score: 0 | Risposta

        Frasubb
        Partecipante
          1 pt

          Ciao, grazie per la tua risposta, il campo Contatore è una sorta di codice cliente ed è espresso in numeri.

          La formula va copiata nella colonna "D"  tutte le volte che effettuo un nuovo inserimento tramite il tasto "INSERISCI" presente nella userform

          #54041 Score: 0 | Risposta

          Frasubb
          Partecipante
            1 pt

            ok grazie a tutti, ho risolto da solo

          Login Registrati
          Stai vedendo 4 articoli - dal 1 a 4 (di 4 totali)
          Rispondi a: Macro con formula ricorrente
          Gli allegati sono permessi solo ad utenti REGISTRATI
          Le tue informazioni: