Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

aide sur modification macro

  • Initiateur de la discussion Initiateur de la discussion bpol
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

bpol

XLDnaute Impliqué
Bonjour,

voilà j'ai une macro qui comporte cette partie là:

'and
Sheets("récap").Select
Ligne = Range("A65536").End(xlUp).Row + 1
Cells(Ligne, 1) = Sheets("tableau").Range("E1")
Cells(Ligne, 2) = Sheets("tableau").Range("H1")
Cells(Ligne, 3) = Sheets("tableau").Range("G1")
Cells(Ligne, 4) = Sheets("tableau").Range("I1")

'and

Worksheets("tableau").Select
'And
ActiveWorkbook.save

mais quand je rajoute cela:

'and
Sheets("récap").Select
Ligne = Range("A65536").End(xlUp).Row + 1
Cells(Ligne, 1) = Sheets("tableau").Range("E1")
Cells(Ligne, 2) = Sheets("tableau").Range("H1")
Cells(Ligne, 3) = Sheets("tableau").Range("G1")
Cells(Ligne, 4) = Sheets("tableau").Range("I1")
'and

If Range("D6") > 0 Then
Sheets("calcul").Select
Ligne = Range("A65536").End(xlUp).Row + 1
Cells(Ligne, 1) = Sheets("tableau").Range("E1")
Cells(Ligne, 2) = Sheets("tableau").Range("H1")
Cells(Ligne, 3) = Sheets("tableau").Range("G1")
Cells(Ligne, 4) = Sheets("tableau").Range("I1")
End If

Worksheets("tableau").Select
'And
ActiveWorkbook.save

la rajoute ne fonctionne pas

quelqu'un pourrait me donner la raison


Merci
Bpol
 
Re : aide sur modification macro

Bonjour Bpol, bonjour à toutes et à tous 🙂


Tout ce que je vois c'est que tu fais une comparaison de la cellule D6 de ta feuille Récap.

Si cela ne vient pas de là, mets un petit fichier exemple en PJ.

@+
 
Re : aide sur modification macro

vu la difficulté à trouver,
voici la macro complète:


Private Sub cmdEnregistrer_Click()
Dim lig As Long
Dim choixLig As Long
Dim col As Long
Dim choixCol As Long

' Trouver la ligne
choixLig = 0

For lig = 7 To 256
If Range("E7") = 0 Then choixLig = 7: Exit For

If Range("E" & lig) = Range("E1") Then choixLig = lig: Exit For

If Range("E" & lig) = 0 And Range("F3") > 1 Then
lig = Range("E65536").End(xlUp).Row + 1
Cells(lig, 5) = Range("E1")
choixLig = lig: Exit For
End If
Next lig

Cells(choixLig, 5) = Range("E1")

' If choixLig = 0 Then
' MsgBox "L'enregistrement n'est pas possible", vbCritical + vbOKOnly, "Erreur"
' Exit Sub
' End If

' Trouver la colonne
choixCol = 0
For col = 6 To 9
If Cells(choixLig, col) = 0 Then
choixCol = col
Exit For
End If
Next col

If choixCol = 0 Then
MsgBox "L'enregistrement n'est pas possible", vbCritical + vbOKOnly, "Erreur"
Exit Sub
End If

' Afficher le résultat
Cells(choixLig, choixCol).Value = Range("I1").Value

'and
Sheets("récap").Select
Ligne = Range("A65536").End(xlUp).Row + 1
Cells(Ligne, 1) = Sheets("tableau").Range("E1")
Cells(Ligne, 2) = Sheets("tableau").Range("H1")
Cells(Ligne, 3) = Sheets("tableau").Range("G1")
Cells(Ligne, 4) = Sheets("tableau").Range("I1")
'and

If Range("D6") > 0 Then
Sheets("calcul").Select
Ligne = Range("A65536").End(xlUp).Row + 1
Cells(Ligne, 1) = Sheets("tableau").Range("E1")
Cells(Ligne, 2) = Sheets("tableau").Range("H1")
Cells(Ligne, 3) = Sheets("tableau").Range("G1")
Cells(Ligne, 4) = Sheets("tableau").Range("I1")
End If

Worksheets("tableau").Select
'And
ActiveWorkbook.save
 
Re : aide sur modification macro

bonjour bpol, bonjour à toutes et à tous 🙂

Je suis désolé mais tu m'avais dit que ton problème était une question de sélection de cellule (sic) or je ne vois aucune différence entre le premier bout de code envoyé et celui-ci 🙄 sinon qu'il est plus long et qu'il n'y a aucune sélection de cellule (dans le code, of course).

En attendant un exemple concret 🙂

@+
 
Re : aide sur modification macro


voici le fichier
http://cjoint.com/?fcgR6dn2qK

bon WE
bpol
 
Re : aide sur modification macro

RE,

PROBLEME RESOLU
remplacé par

If Sheets("tableau").Range("C2") > 0 Then
Sheets("calcul").Select
Ligne = Range("A65536").End(xlUp).Row + 1
Cells(Ligne, 1) = Sheets("tableau").Range("E1")
Cells(Ligne, 2) = Sheets("tableau").Range("H1")
Cells(Ligne, 3) = Sheets("tableau").Range("G1")
Cells(Ligne, 4) = Sheets("tableau").Range("I1")
End If

Merci quand même Nolich


post clôturé!

Bpol
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
1
Affichages
327
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…