Excel工作表运行时错误13:类型不匹配。

时间:2017-03-27 04:06:57

标签: excel vba excel-vba

Sub Reset_Bet()
    Application.ScreenUpdating = False
      Sheets("Bet Angel").Select
            Range( _
                "O6,O9,O11,O13,O15,O17,O19,O21,O23,O25,O27,O29,O31,O33,O35,O37,O39,O41,O43,O45,O47,O49,O51,O53,O55,O57,O59,O61,O63,O65,O67").Activate
            Selection.ClearContents
            Range("H2").Select
            Sheets("Dashboard").Select
            Range("D1").Select
            Worksheets("Dashboard").Range("A26") = 0
    Application.ScreenUpdating = True
End Sub

Sub TIME_CHECK()
    If Worksheets("Dashboard").Range("A26") >= Worksheets("Dashboard").Range("L19") Then Call Reset_Bet
    If Worksheets("Dashboard").Range("A27") >= Worksheets("Dashboard").Range("L20") Then Range("A27") = 0
End Sub

Sub TIMEODD()
    Worksheets("Dashboard").Range("a25") = 1
    **Worksheets("Dashboard").Range("A26") = Range("A26") + 1**
    Worksheets("Dashboard").Range("A27") = Range("A27") + 1
    Call TIME_CHECK
End Sub

Sub TIMEEVEN()
    Worksheets("Dashboard").Range("a25") = 0
    Worksheets("Dashboard").Range("A26") = Range("A26") + 1
    Worksheets("Dashboard").Range("A27") = Range("A27") + 1
    Call TIME_CHECK
End Sub

Public Sub arrRecorder()

    Dim ws As Worksheet
    Set ws = Worksheets("Recorder")
    ' Excel 2003 only has 65536 rows
    Dim maxRows As Long
    maxRows = 65536 ' This value must not be more than the number of rows allowed in Excel

    ' Clear data after selecting a new market, if that option is ticked
    If (ws.Range("A4").Value <> ws.Range("A7").Value) And ws.Range("A7").Value <> "" And ws.Range("D1").Value = True Then
        Module1.Clear_Data
    End If

    ' Check whether logging is enabled
    If (ws.Range("D2") = True) Then

        Application.ScreenUpdating = False

        ' Find the last used row
        Dim lastRow As Long
        lastUsedRow = ws.Cells.SpecialCells(xlCellTypeLastCell).Row

        'Find the last column
        Dim lastUsedColumn As Long
        lastUsedColumn = ws.Cells.SpecialCells(xlCellTypeLastCell).Column

        ' Clear the last used row, so that there is not an error if we try to move data down beyond the last row
        ' Deleting a row is not super fast, so we only do it if necessary.
        ' So we do not bother to delete the last used row unless it is near the end of the spreadsheet
        ' This also ensures that we never accidentally delete our top row containing formulae.
        If lastUsedRow >= maxRows Then
            ' Now delete cells in the last used row (across as far as the lastUsedColumn)
            ws.Range(ws.Cells(lastUsedRow, 1), ws.Cells(lastUsedRow, lastUsedColumn)).Delete
        End If

        ' Now move all the data down by one row, by inserting a row
        ws.Range(ws.Cells(5, 1), ws.Cells(5, lastUsedColumn)).Insert shift:=xlDown

        Dim arr As Variant
        'arr = ws.Range("A3:AF3")
        arr = ws.Range(ws.Cells(4, 1), ws.Cells(4, lastUsedColumn))

        Dim destination As Range
        Set destination = ws.Range("A7")
        destination.Resize(UBound(arr, 1), UBound(arr, 2)).Value = arr
        ' Other ways to copy the data:
        'ws.Range("A7:AF5").Value = arr
        'ws.Range("A7:AF5").Value = ws.Range("A4:AF3").Value
        'ws.Range("A7:AF5").Copy destination: ws.Range ("A4:AF3")

        Application.ScreenUpdating = True
    End If


End Sub

Sub Clear_Data()
    Dim ws As Worksheet
    Set ws = Worksheets("Recorder")
    'ws.Range("A5:AF65536").delete shift:=xlUp
    Dim lastDataColumn As Long
    lastDataColumn = ws.Cells.SpecialCells(xlCellTypeLastCell).Column
    ws.Range(ws.Cells(7, 1), ws.Cells(65536, lastDataColumn)).Clear
End Sub
Sub NotActive()
    Dim ws As Worksheet
    Set ws = Worksheets("Recorder")
    ' Just log it once that the market is not active (i.e. Suspended or Closed)
    ' There is no need to log it more than once, because prices don't change when the market is not active
    If ws.Range("D4") <> ws.Range("D7") Then
        Call arrRecorder
    End If
End Sub

我正在尝试记录投注赔率和记录表,并试图在仪表板中自动下注。录音机工作正常,但它不显示其他表格上的赔率,无论我链接它们。其次,当我启动工作表时,它会给我一个运行时错误错误&#39; 13&#39;:TypeMismatch。当我点击调试时,它会将我带到这一行&#34;工作表(&#34;仪表板&#34;)。范​​围(&#34; A26&#34;)=范围(&#34; A26&#34; )+ 1&#34;

请帮帮我。

1 个答案:

答案 0 :(得分:2)

像这样:

Sub TIMEODD()
    With Worksheets("Dashboard")
        .Range("a25") = 1
        .Range("A26") = .Range("A26") + 1
        .Range("A27") = .Range("A27") + 1
    End With
    Call TIME_CHECK
End Sub