VBA #VALUE错误

时间:2013-09-23 21:01:43

标签: excel vba

当我发布以下内容时,将在应报告终结者的分部排名的单元格中返回#VALUE。它应该比较.Cells(lRow,5)中给出的终结者的分区。值与所有早先完成并返回适当排名(数字1,2等)的值。

   With ws
  .Cells(lRow, 1).Value = Me.DTPicker1.Value 'Date/Time Stamp
  .Cells(lRow, 2).Value = Me.ComboBox1.Value 'Bib Number
  .Cells(lRow, 3).Value = Me.TextBox1.Value 'First Name
  .Cells(lRow, 4).Value = Me.TextBox2.Value 'Last Name
  .Cells(lRow, 5).Value = Me.TextBox6.Value 'Division

  'Compute Division Ranking

  Dim Rng As Range
  Dim c As Range
  Set Rng = Range(Cells(1, 5), Cells(lRow, 5))
  For Each c In Rng
      .Cells(lRow, 6).Value = Application.Rank(c.Value, Rng, 1)
  Next c

1 个答案:

答案 0 :(得分:0)

在黑暗中拍摄:

   With ws
  .Cells(lRow, 1).Value = Me.DTPicker1.Value 'Date/Time Stamp
  .Cells(lRow, 2).Value = Me.ComboBox1.Value 'Bib Number
  .Cells(lRow, 3).Value = Me.TextBox1.Value 'First Name
  .Cells(lRow, 4).Value = Me.TextBox2.Value 'Last Name
  .Cells(lRow, 5).Value = CLng(Me.TextBox6.Value) 'Division

  'Compute Division Ranking

  Dim Rng As Range
  Dim c As Range
  Set Rng = Range(Cells(1, 5), Cells(lRow, 5))
  For Each c In Rng
      .Cells(lRow, 6).Value = Application.Rank(c.Value, Rng, 1)
  Next c