【问题标题】:Type mismatch Excel VBA类型不匹配 Excel VBA
【发布时间】:2014-01-01 15:20:20
【问题描述】:

查看以下代码:

Sub tickscale_table()

exch = Cells(I, 13).Value
Worksheets("tickscale").Activate
Range("A1").Activate


Cells.Find(What:=exch, After:=ActiveCell, LookIn:=xlValues, LookAt:= _
    xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=True _
    , SearchFormat:=False).Activate

 If ms = ActiveCell.Offset(0, 1) And cr = ActiveCell.Offset(0, 3) Then
     tickscaletype = ActiveCell.Offset(0, 4).Value2 And tickcale = ActiveCell.Offset(0,5).Value2

End If

上面是我尝试运行以在 excelsheet 表中搜索值的代码,当在第一列中找到该值时,我会搜索 mscr 的值是否满足同一行,如果条件为真,我使 tickscaletypetickscale 等于同一行中另一列的值。

我的类型不匹配

tickscaletype=ActiveCell.Offset(0,4).value

我尝试将tisckscaletypetickscale 声明为变体、范围、字符串,留空,但仍然出现错误。

【问题讨论】:

    标签: excel vba


    【解决方案1】:

    这段代码对我来说没有意义

    tickscaletype = ActiveCell.Offset(0, 4).Value2 And tickcale = ActiveCell.Offset(0,5).Value2
    

    你应该有

    tickscaletype = ActiveCell.Offset(0, 4).Value2 
    tickcale = ActiveCell.Offset(0,5).Value2
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-28
      • 1970-01-01
      • 1970-01-01
      • 2017-04-12
      相关资源
      最近更新 更多