【问题标题】:Why isn't my code working? [closed]为什么我的代码不起作用? [关闭]
【发布时间】:2013-05-25 10:22:32
【问题描述】:
     Private Sub CommandButton1_Click()
       Dim rTable                 As Range
           Dim lRow                   As Long


        Set rTable = Sheets("Revenue Dashboard").PivotTables("PivotTable6").TableRange1
            With Sheets("Overall Dashboard")
         lRow = Application.Max(.Cells(.Rows.Count, "T").End(xlUp).Row + 1, 63)
       .Range("T" & lRow).Value = rTable.Cells(rTable.Cells.Count).Value
        .Select
       End With
        End Sub




    Private Sub CommandButton2_Click()
    Dim rngInput As Range
       Set rngInput = Sheet1.Range("R63:T69") '
        rngInput.ClearContents
     End Sub


        Private Sub CommandButton3_Click()
        Dim rTable                 As Range
        Dim lRow                   As Long


        Set rTable = Sheets("Impression      Dashboard").PivotTables("PivotTable5").TableRange1
       With Sheets("Overall Dashboard")
          lRow = Application.Max(.Cells(.Rows.Count, "T").End(xlUp).Row + 1, 127)
          .Range("T" & lRow).Value = rTable.Cells(rTable.Cells.Count).Value
            .Select
     End With
       End Sub


         Private Sub CommandButton4_Click()
          Dim rngInput As Range
         Set rngInput = Sheet1.Range("R127:T137") '
         rngInput.ClearContents
      End Sub


       Private Sub CommandButton5_Click()
       Dim rTable                 As Range
      Dim lRow                   As Long


       Set rTable = Sheets("Clicks Dashboard").PivotTables("PivotTable8").TableRange1
       With Sheets("Overall Dashboard")
  lRow = Application.Max(.Cells(.Rows.Count, "S").End(xlUp).Row + 1, 197)
  .Range("S" & lRow).Value = rTable.Cells(rTable.Cells.Count).Value
   .Select
       End With
       End Sub


        Private Sub CommandButton6_Click()
        Dim rngInput As Range
          Set rngInput = Sheet1.Range("Q197:T207") '
           rngInput.ClearContents


         End Sub


      Private Sub CommandButton7_Click()
      Dim slcr As SlicerCache


        For Each slcr In ActiveWorkbook.SlicerCaches

     slcr.ClearManualFilter
    Next slcr
            End Sub

这是针对不同数据集的一系列比较按钮的代码,每个按钮都有一个“清除数据”按钮。最后我有一个“清除切片器”按钮。

它之前可以工作,但在点击几下按钮后,它不再在单元格 T63 中显示数据(对于命令按钮一)

据我所知,代码没有改变 - 是什么导致了问题?

谢谢

【问题讨论】:

    标签: .net vb.net visual-studio-2010


    【解决方案1】:

    这个语句不应该有列引用吗? 代码:

           rTable.Cells(rTable.Cells.Count).Value
    

    【讨论】:

    • 谢谢 您的帮助
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-22
    相关资源
    最近更新 更多