+ Reply to Thread
Results 1 to 5 of 5

Getting Compile Error - Expected Range or Function right after updating to Excel 2016...??

Hybrid View

BG1983 Getting Compile Error -... 03-29-2016, 11:17 PM
6StringJazzer Re: Getting Compile Error -... 03-30-2016, 09:57 AM
BG1983 Re: Getting Compile Error -... 03-30-2016, 10:43 AM
StephenR Re: Getting Compile Error -... 03-30-2016, 10:55 AM
6StringJazzer Re: Getting Compile Error -... 03-30-2016, 11:30 AM
  1. #1
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Getting Compile Error - Expected Range or Function right after updating to Excel 2016...??

    Hi All, so I have been working on this macro for the past day and I happened to also update to Office 2016 today. Now, I am getting a compile error = Expected Variable or Function for every one of my Range or Selection code lines... does anyone know if something changed... or what is happening here? here it the code... first error occurs at line "Range(Selection, Selection.End(xlDown)).Select" right after the Range("Q24").Select line

    Option Explicit
    Sub Hearings()
    '
        Application.ScreenUpdating = False
        Application.StatusBar = False
        Application.DisplayAlerts = False
        Application.EnableEvents = False
        Application.Calculation = xlCalculationManual
    '
        Sheets("FLHearingsMaster").Select
        Range("Q24").Select
        Range(Selection, Selection.End(xlDown)).Select
        Range(Selection, Selection.End(xlToRight)).Select
        Selection.ClearContents
    '
        Dim a, i As Long, myMin As String, AMPM As String, m As Object
        With Range("J24", Range("J" & Rows.Count).End(xlUp))
            a = .Value
            With CreateObject("VBScript.RegExp")
                .IgnoreCase = True
                .Pattern = "(\d{1,2})( *([ap]m)|:(\d{2}) *([ap]m)?|(\d{2}) *([ap]m))"
                For i = 1 To UBound(a, 1)
                    If TypeName(a(i, 1)) = "Double" Then a(i, 1) = _
                    Format$(a(i, 1), "hh:mm am/pm")
                    If .test(a(i, 1)) Then
                        Set m = .Execute(a(i, 1))(0).submatches
                        myMin = m(3) & m(5)
                        If myMin = "" Then myMin = "00"
                        AMPM = m(2) & m(4) & m(6)
                        If Trim$(AMPM) = "" Then
                            Select Case Val(m(0))
                            Case 8 To 11: AMPM = " AM"
                            Case Else: AMPM = " PM"
                            End Select
                        End If
                        If Trim$(AMPM) = "" Then AMPM = " AM"
                        a(i, 1) = m(0) & ":" & myMin & " " & AMPM
                    Else
                        a(i, 1) = ""
                    End If
                Next
            End With
            With .Columns(-4)
                .Value = a: .NumberFormat = "h:mm AM/PM"
            End With
        End With
        Range("M1:N1").Value = Now
    '
        Range("I24").Select
        Range(Selection, Selection.End(xlDown)).Select
        Selection.Copy
        Range("Q24").Select
        ActiveSheet.Paste
        Range("R24").Select
        ActiveSheet.Paste
        Range("S24").Select
        ActiveSheet.Paste
        Range("T24").Select
        ActiveSheet.Paste
        Range("U24").Select
        ActiveSheet.Paste
    '
        ActiveSheet.ListObjects("Table_FLHearingsMaster").Range.AutoFilter Field:=2, _
        Criteria1:=Array("Broward", "Miami-Dade", "Palm Beach"), Operator:=xlFilterValues
        Range("Table_FLHearingsMaster[[#Headers],[Office Coverage]]").Select
        ActiveCell.FormulaR1C1 = "FTL"
        Range("Table_FLHearingsMaster[[#Headers],[FTL]]").Select
        Selection.Copy
        Range(Selection, Selection.End(xlDown)).Select
        ActiveSheet.Paste
        Application.CutCopyMode = False
        ActiveSheet.ShowAllData
    '
        ActiveSheet.ListObjects("Table_FLHearingsMaster").Range.AutoFilter Field:=2, _
        Criteria1:=Array("Hillsborough", "Pasco", "Pinellas"), Operator:=xlFilterValues
        Range("Table_FLHearingsMaster[[#Headers],[FTL]]").Select
        ActiveCell.FormulaR1C1 = "TPA"
        Range("Table_FLHearingsMaster[[#Headers],[TPA]]").Select
        Selection.Copy
        Range(Selection, Selection.End(xlDown)).Select
        ActiveSheet.Paste
        Application.CutCopyMode = False
        ActiveSheet.ShowAllData
    '
        ActiveSheet.ListObjects("Table_FLHearingsMaster").Range.AutoFilter Field:=20 _
        , Criteria1:="<>FTL", Operator:=xlAnd, Criteria2:="<>TPA"
        Range("Table_FLHearingsMaster[[#Headers],[TPA]]").Select
        ActiveCell.FormulaR1C1 = "Other"
        Range("Table_FLHearingsMaster[[#Headers],[Other]]").Select
        Selection.Copy
        Range(Selection, Selection.End(xlDown)).Select
        ActiveSheet.Paste
        Range("Table_FLHearingsMaster[[#Headers],[Other]]").Select
        ActiveCell.FormulaR1C1 = "Office Coverage"
        Application.CutCopyMode = False
        ActiveSheet.ShowAllData
    '
        ActiveSheet.ListObjects("Table_FLHearingsMaster").Range.AutoFilter Field:=4 _
        , Criteria1:=""
        Range("Table_FLHearingsMaster[[#Headers],[Hearing Time]]").Select
        ActiveCell.FormulaR1C1 = "Missing"
        Range("Table_FLHearingsMaster[[#Headers],[Missing]]").Select
        Selection.Copy
        Range(Selection, Selection.End(xlDown)).Select
        ActiveSheet.Paste
        Application.CutCopyMode = False
        Range("Table_FLHearingsMaster[[#Headers],[Missing]]").Select
        ActiveCell.FormulaR1C1 = "Hearing Time"
        ActiveSheet.ShowAllData
    '
        ActiveSheet.ListObjects("Table_FLHearingsMaster").Range.AutoFilter Field:=7, _
        Criteria1:="="
        Range("Table_FLHearingsMaster[[#Headers],[Attorney Attending Hearing]]").Select
        ActiveCell.FormulaR1C1 = "Missing"
        Range("Table_FLHearingsMaster[[#Headers],[Missing]]").Select
        Selection.Copy
        Range(Selection, Selection.End(xlDown)).Select
        ActiveSheet.Paste
        Range("Table_FLHearingsMaster[[#Headers],[Missing]]").Select
        Application.CutCopyMode = False
        ActiveCell.FormulaR1C1 = "Attorney Attending Hearing"
        ActiveSheet.ShowAllData
    '
        Application.Calculation = xlCalculationAutomatic
        Range("$R$24").Select
        ActiveCell.FormulaR1C1 = "=IF((RC[-10]=""Missing""), ""Yes"", ""No"")"
        Range("$R$24").Select
        Range("$R$24").Copy
        Selection.AutoFill Destination:=Range( _
        "Table_FLHearingsMaster[Missing Hearing Attorney]")
        Columns("R:R").Copy
        Columns("R:R").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
        Application.CutCopyMode = False
    '
        Range("$Q$24").Select
        ActiveCell.FormulaR1C1 = "=TEXT(RC[-13],""mmm-yyyy "")"
        Range("$Q$24").Select
        Range("$Q$24").Copy
        Selection.AutoFill Destination:=Range( _
        "Table_FLHearingsMaster[Hearing Month  Year]")
        Columns("Q:Q").Copy
        Columns("Q:Q").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
        Application.CutCopyMode = False
    '
        Range("S24").Select
        ActiveCell.FormulaR1C1 = "=IF((RC[-14]=""Missing""), ""Yes"", ""No"")"
        Range("S24").Select
        Selection.Copy
        Application.CutCopyMode = False
        Selection.AutoFill Destination:=Range( _
        "Table_FLHearingsMaster[Missing Hearing Time]")
    '
        Range("$T$24").Select
        ActiveCell.FormulaR1C1 = "=IF((RC[-5]>=TODAY()),""Yes"", ""No"")"
        Range("$T$24").Select
        Range("$T$24").Copy
        Selection.AutoFill Destination:=Range( _
        "Table_FLHearingsMaster[Sale Date Set]")
        Columns("T:T").Copy
        Columns("T:T").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
        Application.CutCopyMode = False
        Application.Calculation = xlCalculationManual
    '
        Rows("22:22").Select
        Selection.NumberFormat = "0"
        Range("Table_FLHearingsMaster").Select
        Selection.Borders(xlDiagonalDown).LineStyle = xlNone
        Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        Selection.Borders(xlEdgeLeft).LineStyle = xlNone
        Selection.Borders(xlEdgeTop).LineStyle = xlNone
        Selection.Borders(xlEdgeBottom).LineStyle = xlNone
        Selection.Borders(xlEdgeRight).LineStyle = xlNone
        Selection.Borders(xlInsideVertical).LineStyle = xlNone
        Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    '
        Range("Table_FLHearingsMaster[#All]").Select
        ActiveWorkbook.Worksheets("FLHearingsMaster").ListObjects( _
            "Table_FLHearingsMaster").Sort.SortFields.Clear
        ActiveWorkbook.Worksheets("FLHearingsMaster").ListObjects( _
            "Table_FLHearingsMaster").Sort.SortFields.Add Key:=Range( _
                "Table_FLHearingsMaster[New Hearing Date]"), SortOn:=xlSortOnValues, Order _
                     :=xlAscending, DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets("FLHearingsMaster").ListObjects( _
            "Table_FLHearingsMaster").Sort.SortFields.Add Key:=Range( _
                "Table_FLHearingsMaster[County]"), SortOn:=xlSortOnValues, Order:= _
                     xlAscending, DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets("FLHearingsMaster").ListObjects( _
            "Table_FLHearingsMaster").Sort.SortFields.Add Key:=Range( _
                "Table_FLHearingsMaster[Hearing Time]"), SortOn:=xlSortOnValues, Order:= _
                    xlAscending, DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets("FLHearingsMaster").ListObjects( _
            "Table_FLHearingsMaster").Sort.SortFields.Add Key:=Range( _
                "Table_FLHearingsMaster[Attorney Attending Hearing]"), SortOn:=xlSortOnValues _
                    , Order:=xlAscending, DataOption:=xlSortNormal
        With ActiveWorkbook.Worksheets("FLHearingsMaster").ListObjects( _
            "Table_FLHearingsMaster").Sort
            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
    '
        Application.Calculation = xlCalculationAutomatic
        Range("BI24").Select
        ActiveCell.FormulaR1C1 = "=CLEAN((TRIM(PROPER(RC[-51]))))"
        Range("BI24").Select
        Selection.Copy
        Range(Selection, Selection.End(xlDown)).Select
        ActiveSheet.Paste
        Columns("BI:BI").Copy
        Columns("BI:BI").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
        Range("BI24").Select
        Range("BI24").Copy
        Range(Selection, Selection.End(xlDown)).Select
        Selection.Copy
        Range("J24").Select
        ActiveSheet.Paste
        Application.CutCopyMode = False
        With Selection
            .HorizontalAlignment = xlLeft
        End With
        Application.Calculation = xlCalculationManual
    '
        Columns("BI:BI").Delete Shift:=xlToLeft
        Range("Table_FLHearingsMaster[#All]").Select
        Selection.Borders(xlDiagonalDown).LineStyle = xlNone
        Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With Selection.Borders(xlEdgeLeft)
            .LineStyle = xlContinuous
            .Weight = xlThin
        End With
        With Selection.Borders(xlEdgeTop)
            .LineStyle = xlContinuous
            .Weight = xlThin
        End With
        With Selection.Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .Weight = xlThin
        End With
        With Selection.Borders(xlEdgeRight)
            .LineStyle = xlContinuous
            .Weight = xlThin
        End With
        With Selection.Borders(xlInsideVertical)
            .LineStyle = xlContinuous
            .Weight = xlThin
        End With
        With Selection.Borders(xlInsideHorizontal)
            .LineStyle = xlContinuous
            .Weight = xlThin
        End With
        Selection.RowHeight = 13
    '
        ActiveWindow.ScrollColumn = 1
        Cells.Select
    '
        Application.ScreenUpdating = True
        Application.StatusBar = True
        Application.DisplayAlerts = True
        Application.EnableEvents = True
        Application.Calculation = xlCalculationAutomatic
    End Sub

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner VA USA
    MS-Off Ver
    MS 365 Family 64-bit 2505
    Posts
    27,439

    Re: Getting Compile Error - Expected Range or Function right after updating to Excel 2016.

    I do not know why these are causing compile errors. I am not getting any compile errors in Excel 2016, although I cannot actually run this without your file.

    In the meantime, I discourage selecting cells to do anything with them. It slows down performance and clogs up the code. For example, I would modify this
        Range("Q24").Select
        Range(Selection, Selection.End(xlDown)).Select
        Range(Selection, Selection.End(xlToRight)).Select
        Selection.ClearContents
    To this
        Dim C As Range
        Set C = Range("Q24")
        Range(C, C.SpecialCells(xlLastCell)).ClearContents
    and change this
     Range("Table_FLHearingsMaster[[#Headers],[Office Coverage]]").Select
        ActiveCell.FormulaR1C1 = "FTL"
    to this
     Range("Table_FLHearingsMaster[[#Headers],[Office Coverage]]").FormulaR1C1 = "FTL"
    You have lots and lots and lots of these types of constructs. This may have the added benefit of clearing the compiler error.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Getting Compile Error - Expected Range or Function right after updating to Excel 2016.

    Okay, thanks! I will clean it up and retry

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Getting Compile Error - Expected Range or Function right after updating to Excel 2016.


  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner VA USA
    MS-Off Ver
    MS 365 Family 64-bit 2505
    Posts
    27,439

    Re: Getting Compile Error - Expected Range or Function right after updating to Excel 2016.

    BG1983, your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

+ 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] If err.number... gives expected function or variable in Excel 2016
    By BuZZarD73 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-26-2016, 11:18 AM
  2. Getting compile error expected function or variable
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-10-2014, 01:33 AM
  3. [SOLVED] Function Error: Compile error: Expected: list separator or )
    By goss in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-05-2014, 02:10 PM
  4. [SOLVED] Compile Error Expected Function or Variable
    By shiser in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-22-2014, 09:18 AM
  5. [SOLVED] With my user defined function... Compile Error: Expected: =
    By kid_epicurus in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-01-2012, 04:03 PM
  6. Compile Error:- expected function or variable problem
    By skin.uk1 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-08-2011, 02:56 PM
  7. Compile error: Expected Sub, Function, or Property
    By Cloudfall in forum Excel General
    Replies: 3
    Last Post: 08-30-2005, 01:05 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