不能递增Cmd下一步

下面的代码应该是当input表单击一个button时得到下一个logging。

我单击它时,我的button被命名为CurrRecNew在执行下面的代码,但它似乎不会增加。 任何build议,我在做什么错?

数据表单1具有单元格,从行A3开始,然后例如

A3 1 B3 a
A4空白B4 b
A5空白B5 c
A6 2 B6 d
A7空白B7 f
A8空白B8 g
A9空白B9 h
A8 3 B10 …

Sub ViewLogDown() Dim historyWks As Worksheet Dim InputWks As Worksheet Dim lRec As Long Dim lRecRow As Long Dim lLastRec As Long Dim LastRow As Long Dim Rlen As Long Dim lCurrentRow As Long lCurrentRow = lCurrentRow + 1 Application.EnableEvents = False Set InputWks = Worksheets("Sheet3") Set historyWks = Worksheets("Sheet1") With historyWks LastRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row - 1 lLastRec = LastRow - 1 End With With InputWks lCurrentRow = lCurrentRow + 1 lRec = .Range("CurrRecNew").Value Do While Len(Cells(lCurrentRow, 1).Value) = 0 lCurrentRow = lCurrentRow + 1 Loop lCurrentRow = lCurrentRow - 1 .OLEObjects("tbRiskID").Object.Value = historyWks.Cells(lCurrentRow, 1) .OLEObjects("tbRiskContext").Object.Value = historyWks.Cells(lCurrentRow, 2) .OLEObjects("TextBox34").Object.Value = historyWks.Cells(lCurrentRow, 3) .OLEObjects("tbRiskEx").Object.Value = historyWks.Cells(lCurrentRow, 4) .OLEObjects("tbRiskCat").Object.Value = historyWks.Cells(lCurrentRow, 5) End With Application.EnableEvents = True End Sub 

你的代码非常混乱,你可以在InputWks表单上findlCurrentRow,然后将文本框对象设置为Historywks表单上的lcurrentrow? 你需要清楚地解释每个工作表的作用,你想find下一行的表单等。

我认为你正在使用命名的范围CurrRecNew来存储当前行。 你想要获得历史工作者表中的当前行。 因此,至于find下一行,这是你的实际问题你的代码应该是这样的:

  Dim rFound As Range '// History sheet With historyWks '// Get current row, you need to correctly define the sheet name which contains the CurrRecNew Range. lCurrentRow = InputWks.Range("CurrRecNew").Value Set rFound = .Columns(1).Find(What:="*", After:=.Cells(lCurrentRow, 1)) If Not rFound Is Nothing Then If rFound.Row > lCurrentRow Then lCurrentRow = rFound.Row txtName.Text = Cells(lCurrentRow, 1).Value txtPhone.Text = Cells(lCurrentRow, 2).Value End If End If '// Once again correct the sheet name here I guessed CurrRecNew was on the InputWks sheet InputWks.Range("CurrRecNew").Value = lCurrentRow End with