MotorCityCanuk
New Member
- Joined
- May 10, 2018
- Messages
- 1
Good morning. My son is learning Excel macros and he has run into an issue that has me stumped. He is recording a very simple excel macro on Excel 2016 that generates syntax errors when you attempt to run it. Looking at the generated code (posted below) it's clearly not going to run. The puzzling thing is that I record the exact same steps on my machine (also Excel 2016) and get a fully functional version of the macro, also posted below. Is it possible that there setting(s) on his system that could be causing these issues? Puzzled in the motor city....
Code with Syntax Error:
Code without Syntax Errors:
Code with Syntax Error:
Code:
Sub FormatCells()'
' FormatCells Macro
'
'
[COLOR=#ff0000] Application. = FALSE[/COLOR]
With .Color
.MeasureName = "Arial"
.ErrorString = 11
.HasAutoFormat = False
.MergeLabels = False
.PageFieldOrder = False
.NullString = False
.ActiveSheet = False
.PreserveFormatting = xlUnderlineStyleNone
.Order = xlThemeColorLight1
.Symbol = 0
.PrintDrillIndicators = xlThemeFontNone
End With
With .Color
.MeasureName = "Arial"
.ErrorString = 14
.HasAutoFormat = False
.MergeLabels = False
.PageFieldOrder = False
.NullString = False
.ActiveSheet = False
.PreserveFormatting = xlUnderlineStyleNone
.Order = xlThemeColorLight1
.Symbol = 0
.PrintDrillIndicators = xlThemeFontNone
End With
.Color.ShowDrillIndicators = True
[COLOR=#ff0000] With[/COLOR]
[COLOR=#ff0000] . = xlCenter[/COLOR]
[COLOR=#ff0000] . = xlBottom[/COLOR]
[COLOR=#ff0000] . = FALSE[/COLOR]
[COLOR=#ff0000] . = 0[/COLOR]
[COLOR=#ff0000] . = FALSE[/COLOR]
[COLOR=#ff0000] . = 0[/COLOR]
[COLOR=#ff0000] . = FALSE[/COLOR]
[COLOR=#ff0000] . = xlContext[/COLOR]
[COLOR=#ff0000] . = FALSE[/COLOR]
End With
ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.ErrorString
. [COLOR=#ff0000]:= xlUp[/COLOR]
Columns("A:A").ErrorString
. [COLOR=#ff0000]:= xlToLeft[/COLOR]
End Sub
Code without Syntax Errors:
Code:
Sub Macro1()
'
' Macro1 Macro
'
'
With Selection.Font
.Name = "Arial"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
With Selection.Font
.Name = "Arial"
.Size = 14
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Selection.Font.Bold = True
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select
Selection.Delete Shift:=xlUp
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
End Sub
Last edited by a moderator: