Simple Recorded Macro Syntax Errors

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:
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:

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Does your son's machine have any add-ins?
Also looks like your son recorded the macro on a Pivot, did you do the same?
 
Upvote 0
Cross posted https://www.excelforum.com/excel-pr...rded-macro-has-syntax-errors.html#post4897199

Cross-Posting
While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top