comment modifier ma macro

  • Initiateur de la discussion Initiateur de la discussion fenec
  • 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 !

fenec

XLDnaute Impliqué
Bonjour le forum
J’utilise cette macro pour archiver mes factures mais je rencontre un problème la cellule "I13" contient une formule que je ne souhaite par copier sur ma sauvegarde est ce possible que de ne copier que la valeur ?
D’avance merci
Cordialement
Fenec


Private Sub CommandButton3_Click() 'Archiver Factures
Application.ScreenUpdating = False
NomFichier = ActiveWorkbook.Name
défaut = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 1
Workbooks.Add
Application.SheetsInNewWorkbook = défaut
nomfichier1 = ActiveWorkbook.Name
Me.Cells.Copy ActiveSheet.[A1]
ActiveSheet.Cells.Clear
With Me.Range("Zone_d_impression")
.Copy ActiveSheet.[B2]
ActiveSheet.[B2].Resize(.Rows.Count, .Columns.Count).Locked = True
ActiveSheet.PageSetup.PrintArea = "$B$2:$J$58"
With ActiveSheet.PageSetup
.RightHeader = "Page &P de &N"
.CenterFooter = _
"S.A.R.L au capital de "
.LeftMargin = Application.InchesToPoints(0)
.RightMargin = Application.InchesToPoints(0)
.TopMargin = Application.InchesToPoints(0.393700787401575)
.BottomMargin = Application.InchesToPoints(0)
.HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0.196850393700787)
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlPortrait
.Zoom = 59
End With
ActiveSheet.Protect
ActiveSheet.Range("B6").Select
ChDir "C:\Users\Philippe\Mes documents\Archives\Factures"
fermer = Application.GetSaveAsFilename(ActiveSheet.Range("E13").Value & " " & Range("I14"), "Fichiers Excel,*.xls")
If fermer = False Then
Windows(nomfichier1).Activate
ActiveWorkbook.Close savechanges:=False
Exit Sub
End If
ActiveWorkbook.SaveAs Filename:=fermer
ActiveWorkbook.Close
NonClient = Range("E13")
num = Format(Val(Right(Range("I14"), 3)) + 1, "000")
ActiveSheet.Unprotect
Range("I2") = num
Range("Zone_a_remplir_Facture") = Empty
Range("I13").Select
Workbooks("Bons de Commande & Facture").Activate
ActiveWorkbook.Save
Application.ScreenUpdating = True
End With
End Sub
 
Re : comment modifier ma macro

Bonjour Fenec,

Le plus simple est le plus rapide, rajouter à la fin de ton code :

VB:
[I3] = [I3]

Tout simplement 😉

Bonne après midi

Edition : Salut BrunoM45, j'ai changé mes balises. J'ai même fait mieux, j'ai utilisé les balises
VB:
 
Dernière édition:
Re : comment modifier ma macro

Bonjour Fenec,

Merci de mettre le code entre balises
Code:
 [/ Code] (sans espace après [/)

Pour ton problème il suffit de faire
[code]Range("I13").Value = Range("I13")

Edit : Salut Excel-lent, perso je préfère mettre les instructions VBA 😱

A+
 
comment modifier ma macro [ résolu ]

Bonjour le forum et merci Excel-lent et BrunoM45

Grâce à votre aide je m’en suis sorti avec une petite modification néanmoins.
Décidément j’en apprends beaucoup avec ce forum
Encore merci
Je vous joint mon code modifié grâce à vous (en bleu)
Cordialement
Fenec


Private Sub CommandButton3_Click() 'Archiver Factures
Application.ScreenUpdating = False
NomFichier = ActiveWorkbook.Name
défaut = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 1
Workbooks.Add
Application.SheetsInNewWorkbook = défaut
nomfichier1 = ActiveWorkbook.Name
Me.Cells.Copy ActiveSheet.[A1]
ActiveSheet.Cells.Clear
With Me.Range("Zone_d_impression")
Range("I14").Value = Range("I14") .Copy ActiveSheet.[B2]
ActiveSheet.[B2].Resize(.Rows.Count, .Columns.Count).Locked = True


ActiveSheet.PageSetup.PrintArea = "$B$2:$J$58"
With ActiveSheet.PageSetup

.RightHeader = "Page &P de &N"

.CenterFooter = _
"S.A.R.L au capital de …..."

.LeftMargin = Application.InchesToPoints(0)
.RightMargin = Application.InchesToPoints(0)
.TopMargin = Application.InchesToPoints(0.393700787401575)
.BottomMargin = Application.InchesToPoints(0)
.HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0.196850393700787)

.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlPortrait

.Zoom = 59

End With
ActiveSheet.Protect
ActiveSheet.Range("B6").Select
ChDir "C:\Users\Philippe\Mes documents\Archives\Factures"
fermer = Application.GetSaveAsFilename(ActiveSheet.Range("E13").Value & " " & Range("I14"), "Fichiers Excel,*.xls")
If fermer = False Then
Windows(nomfichier1).Activate
ActiveWorkbook.Close savechanges:=False
Exit Sub
End If
ActiveWorkbook.SaveAs Filename:=fermer
ActiveWorkbook.Close
NonClient = Range("E13")
num = Format(Val(Right(Range("I14"), 3)) + 1, "000")
ActiveSheet.Unprotect
Range("I2") = num
Range("Zone_a_remplir_Facture") = Empty

Range("I14").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = _
"=TEXT(MONTH(TODAY()),""00"")&"" ""&YEAR(TODAY())&"" ""&TEXT(R[-12]C,""000"")"
Range("I13").Select


Workbooks("Bons de Commande & Facture").Activate

ActiveWorkbook.Save
Application.ScreenUpdating = True
End With

End Sub
 
Dernière édition:
- 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
662
Réponses
0
Affichages
1 K
Réponses
6
Affichages
2 K
Retour