Copier du formulaire vers tableau

Bonjour à tous

J'ai un bout de code dans mon fichier qui permet de copier les données du formulaire vers mon tableau excel.

Mais je voudrai éviter l’écriture dans les cellule qui comporte des formules (Colonne G,I et J).

Je n'ai pas d'idée comment éviter cela

Voici mon code

Private Sub b_valid_Click() 'bouton modif
    If Me.Enreg <> "" And Me.TextBox1 <> "" Then
      NoEnreg = Me.Enreg
      For k = 4 To Ncol    'k = decalage de colone
         x = Replace(Me("textBox" & k), " ", "")

           If Me("textbox" & k) <> "" Then
               f.Cells(NoEnreg, k) = Me("textBox" & k)
           Else
               f.Cells(NoEnreg, k) = Empty
           End If

      Next k

      UserForm_Initialize
    End If
End Sub

Merci d'avance et bonne journée

Bonjour,

ajoute après l’instruction for une instruction if k<>7 and k<>9 and k<>10 then

Bonjour,

ajoute après l’instruction for une instruction if k<>7 and k<>9 and k<>10 then

Bonjour Steelson

Merci pour ton message, mais je le place ou exactement?

Bonne journée

Bonjour netparty, Steelson , le forum,

ajoute après l’instruction for une instruction if k<>7 and k<>9 and k<>10 then

Private Sub b_valid_Click() 'bouton modif
    If Me.Enreg <> "" And Me.TextBox1 <> "" Then
       NoEnreg = Me.Enreg
      For k = 4 To Ncol    'k = decalage de colone
       If k <> 7 And k <> 9 And k <> 10 Then
         x = Replace(Me("textBox" & k), " ", "")
           If Me("textbox" & k) <> "" Then
               f.Cells(NoEnreg, k) = Me("textBox" & k)
           Else
               f.Cells(NoEnreg, k) = Empty
           End If
       End If
      Next k
      UserForm_Initialize
    End If
End Sub

où autre possibilité....

Private Sub b_valid_Click() 'bouton modif
    If Me.Enreg <> "" And Me.TextBox1 <> "" Then
       NoEnreg = Me.Enreg
      For k = 4 To Ncol    'k = decalage de colone
       Select Case k
        Case Is = 7, 9, 10 'colonnes à exclure
        Else
          x = Replace(Me("textBox" & k), " ", "")
           If Me("textbox" & k) <> "" Then
              f.Cells(NoEnreg, k) = Me("textBox" & k)
           Else
              f.Cells(NoEnreg, k) = Empty
           End If
        End Select
      Next k
      UserForm_Initialize
    End If
End Sub

Cordialement,

Merci je test

bonne journée

Rechercher des sujets similaires à "copier formulaire tableau"