Erreur VBA sur fonction CONCATENER

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

M

MNPALLARO

Guest
Bonjour,

J'utilise très peu excel, j'ai créé une macro qui contient la fonction CONCATENER mais a l'exécution de la macro cela ne fonctionne pas. Voici la ligne concernée.

ActiveCell.FormulaR1C1 =CONCATENATE(RC[-2],"" "",RC[-1])"

Si quelqu'un peut m'aider ? Désolée de mon ignorance....

Merci d'avance.
Marie-Noëlle.
 
Re : Erreur VBA sur fonction CONCATENER

Ci-joint mon fichier de départ et ci-dessous la macro.
Sub Macro1()
'
' Macro1 Macro
'

'
Columns("F:K").Select
Selection.Delete Shift:=xlToLeft
Columns("G:L").Select
Selection.Delete Shift:=xlToLeft
Selection.Delete Shift:=xlToLeft
Rows("1:1").Select
Selection.RowHeight = 20
Selection.RowHeight = 25
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection.Font
.Name = "Calibri"
.FontStyle = "Gras"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Columns("A:A").Select
Selection.ColumnWidth = 10
Columns("B:B").Select
Selection.ColumnWidth = 13
Columns("C:C").Select
Selection.ColumnWidth = 7
Columns("F:F").Select
Selection.ColumnWidth = 9
Rows("1:1").Select
Selection.RowHeight = 30
Range("G1").Select
ActiveCell.FormulaR1C1 = "Date exercice N"
With ActiveCell.Characters(Start:=1, Length:=15).Font
.Name = "Calibri"
.FontStyle = "Gras"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Range("H1").Select
ActiveCell.FormulaR1C1 = "Date exercice N-1"
With ActiveCell.Characters(Start:=1, Length:=17).Font
.Name = "Calibri"
.FontStyle = "Gras"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Range("I1").Select
ActiveCell.FormulaR1C1 = "Plan comptable"
With ActiveCell.Characters(Start:=1, Length:=14).Font
.Name = "Calibri"
.FontStyle = "Gras"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Range("J1").Select
ActiveCell.FormulaR1C1 = "Activité"
With ActiveCell.Characters(Start:=1, Length:=8).Font
.Name = "Calibri"
.FontStyle = "Gras"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Columns("G:H").Select
Selection.ColumnWidth = 21
Columns("I:I").Select
Selection.ColumnWidth = 10
Columns("J:J").Select
Selection.ColumnWidth = 15
Columns("F:F").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("F2").Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[-2],"" "",RC[-1])"
Selection.AutoFill Destination:=Range("F2:F493"), Type:=xlFillDefault
Range("F2:F493").Select
ActiveWindow.LargeScroll Down:=-20
Columns("F:F").EntireColumn.AutoFit
Columns("F:F").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("D1").Select
Application.CutCopyMode = False
Selection.Copy
Range("F1").Select
ActiveSheet.Paste
Columns("D:E").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
Rows("2:2").Select
Selection.RowHeight = 20
Rows("2:317").Select
Selection.RowHeight = 20
Columns("E:E").Select
With Selection
.HorizontalAlignment = xlGeneral
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("A1😀1").Select
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.118110236220472)
.RightMargin = Application.InchesToPoints(0.118110236220472)
.TopMargin = Application.InchesToPoints(0.354330708661417)
.BottomMargin = Application.InchesToPoints(0.354330708661417)
.HeaderMargin = Application.InchesToPoints(0.31496062992126)
.FooterMargin = Application.InchesToPoints(0.31496062992126)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""
End With
ActiveWindow.SelectedSheets.PrintPreview
Columns("A:A").Select
Selection.ColumnWidth = 8
ActiveWindow.SelectedSheets.PrintPreview
End Sub
 

Pièces jointes

Re : Erreur VBA sur fonction CONCATENER

Ce n'est pas ta fonction CONCATENATE qui pose problème.

Tu as visiblement utilisé l'enregistreur de macros pour faire cette macro, qui je le pense t'a mis tout un tas de code que tu ne comprends pas (pas plus que moi d'ailleurs...)

En tout cas, sur ma version d'Excel (2011 pour MAC), les lignes suivantes plantent :

.PrintQuality = 600
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""

Pour le reste, toi seule sait si la macro fait ce que tu veux qu'elle fasse. Mais je te suggère de rentrer dans le code, de tenter de le comprendre et de faire le tri, car il y a plein de mise en forme dont je doute que tu veuilles la faire à chaque fois que tu exécute ta macro.

A+
dionys0s
 
Re : Erreur VBA sur fonction CONCATENER

Quand j'exécute la macro j'ai un méssage Visual Basic Erreur d'exécution '1004'
Fin ou débogage quand je clique sur débogage ça me renvoie à la ligne concatener.
 
- 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
Assurez vous de marquer un message comme solution pour une meilleure transparence.

Discussions similaires

Réponses
4
Affichages
481
Retour