Erreur VBA sur fonction CONCATENER

MNPALLARO

XLDnaute Nouveau
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.
 

MNPALLARO

XLDnaute Nouveau
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:D1").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

  • PM.XLSX
    15.7 KB · Affichages: 73

dionys0s

XLDnaute Impliqué
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
 

tashiqi

XLDnaute Occasionnel
Re : Erreur VBA sur fonction CONCATENER

Re
Est-ce que tu peux tester avec ce fichier et envoyer un screenshot de l'erreur ?

EDIT : Pour que ce soit plus simple, il suffit d'appuyer sur le bouton ;)
 

Pièces jointes

  • PM.xlsm
    28 KB · Affichages: 65

Discussions similaires

Réponses
14
Affichages
645

Membres actuellement en ligne

Statistiques des forums

Discussions
312 196
Messages
2 086 101
Membres
103 116
dernier inscrit
kutobi87