2013-09-23 138 views
0

當我發佈以下內容時,應在報告裝訂器的「分區排名」的單元格中返回#VALUE。它應該將.Cells(lRow,5).Value中給出的完成者的分數與之前完成的所有人進行比較並返回適當的排名(數字1,2等)。VBA #VALUE錯誤

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 

回答

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 
+0

我提出建議的更新,但收到以下錯誤信息:運行時錯誤「13」:類型不匹配。想法? – user2532363

+0

@ user2532363當excel認爲數字實際上是文本(通常是因爲它被格式化爲常規或文本)時,通常會收到#VALUE錯誤,我試圖通過這種方式嘗試將「TextBox6.Value」轉換爲一個數字,確保你的列'D'被格式化爲一個數字,如果它是一個數字。 – user2140261

+0

沒有快樂。仍然收到#VALUE錯誤。 D列被格式化爲一個數字。 – user2532363