+ Reply to Thread
Results 1 to 2 of 2

VBA Compile Error/Syntax Error

  1. #1
    Registered User
    Join Date
    07-15-2017
    Location
    Nashville, TN
    MS-Off Ver
    2010
    Posts
    1

    VBA Compile Error/Syntax Error

    Receiving a compile/syntax error with the code below beginning with ActiveSheet.Range("$1:$778").RemoveDuplicates Columns := Array. Can someone please suggest a fix to this issue?

    Sub Song_Entry_KPI()
    '
    ' Song_Entry_KPI Macro
    '

    '
    Columns("B:B").Select
    Selection.Replace What:="RE: ", Replacement:="", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    Selection.Replace What:="RE: ", Replacement:="", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    Selection.Replace What:="FW:", Replacement:="", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    Selection.Replace What:="Fwd:", Replacement:="", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    Selection.Replace What:="AW:", Replacement:="", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    Selection.Replace What:="SV:", Replacement:="", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    Selection.Replace What:="WG:", Replacement:="", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    Columns("C:C").Select
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Range("C2").Select
    ActiveCell.FormulaR1C1 = "=TRIM(RC[-1])"
    Range("C2").Select
    Selection.AutoFill Destination:=Range("C2:C778")
    Range("C2:C778").Select
    Columns("C:C").Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Range("B1").Select
    Application.CutCopyMode = False
    Selection.Cut
    Range("C1").Select
    ActiveSheet.Paste
    Columns("B:B").Select
    Selection.Delete Shift:=xlToLeft
    Cells.Select
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("C2:C778") _
    , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Sheet1").Sort
    .SetRange Rows("1:778")
    .Header = xlYes
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
    .Apply
    End With
    ActiveSheet.Range("$1:$778").RemoveDuplicates Columns := Array(2,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523 _
    ,524,525,526,527,528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,559,560,561,562 _
    ,563,564,565,566,567,568,569,570,571,572,573,574,575,576,577,578,579,580,581,582,583,584,585,586,587,588,589,590,591,592,593,594,595,596,597,598,599,600,601 _
    ,602,603,604,605,606,607,608,609,610,611,612,613,614,615,616,617,618,619,620,621,622,623,624,625,626,627,628,629,630,631,632,633,634,635,636,637,638,639,640 _
    ,641,642,643,644,645,646,647,648,649,650,651,652,653,654,655,656,657,658,659,660,661,662,663,664,665,666,667,668,669,670,671,672,673,674,675,676,677,678,679 _
    ,680,681,682,683,684,685,686,687,688,689,690,691,692,693,694,695,696,697,698,699,700,701,702,703,704,705,706,707,708,709,710,711,712,713,714,715,716,717,718 _
    ,719,720,721,722,723,724,725,726,727,728,729,730,731,732,733,734,735,736,737,738,739,740,741,742,743,744,745,746,747,748,749,750,751,752,753,754,755,756,757 _
    ,758,759,760,761,762,763,764,765,766,767,768,769,770,771,772,773,774,775,776,777,778,779,780,781,782,783,784,785,786,787,788,789,790,791,792,793,794,795,796 _
    ,797,798,799,800,801,802,803,804,805,806,807,808,809,810,811,812,813,814,815,816,817,818,819,820,821,822,823,824,825,826,827,828,829,830,831,832,833,834,835 _
    ,836,837,838,839,840,841,842,843,844,845,846,847,848,849,850,851,852,853,854,855,856,857,858,859,860,861,862,863,864,865,866,867,868,869,870,871,872,873,874 _
    ,875,876,877,878,879,880,881,882,883,884,885,886,887,888,889,890,891,892,893,894,895,896,897,898,899,900,901,902,903,904,905,906,907,908,909,910,911,912,913 _
    ,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,930,931,932,933,934,935,936,937,938,939,940,941,942,943,944,945,946,947,948,949,950,951,952 _
    End Sub

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: VBA Compile Error/Syntax Error

    Please Login or Register  to view this content.
    The only guess I'll hazard - your code is frightening.

    You have a line ending with a line Continuation character but the array brackets are not closed and the 'End Sub' needs to be on a line by itself or at least with a Statement Separator (:) before it...


    Also:
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Compile Error - Syntax Error
    By dpforumsetc in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-13-2015, 10:35 AM
  2. Compile Error : Syntax Error
    By masond3 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-06-2014, 10:59 AM
  3. Excel macro (compile error. syntax error.) error
    By salar_younis in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-06-2014, 06:11 AM
  4. [SOLVED] first timer using VB to cut and paste macro - getting compile error syntax error
    By jopedder in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-24-2013, 11:45 AM
  5. [SOLVED] Compile Error : Syntax Error
    By sagar007 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-23-2013, 08:29 AM
  6. [SOLVED] Compile Error: Expected Expression, Syntax Error
    By gjohn282 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-20-2012, 11:28 PM
  7. Syntax Error and Compile Error: Expected Line Number or Label...
    By AnthonyWB in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-31-2011, 09:59 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1