English 中文(简体)
Cmd
原标题:Can t Increment Cmd Next
  • 时间:2011-10-31 09:25:19
  •  标签:
  • excel
  • vba

下面的代码是在输入表上点击ton子时,应当有下一个记录。

My button is named CurrRecNew on sheet3 when I click it performs the code below but it doesn t appear to increment. Any suggestions on what I am doing wrong?

数据表1的电池从罗·阿3开始,排在后面。

A3 1 B3 a
A4 Blank B4 b
A5 Blank B5 c
A6 2 B6 d
A7 Blank B7 f
A8 Blank B8 g
A9 Blank 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
最佳回答

你的守则非常令人困惑,你在投稿上找到了灯塔,然后把文字箱放在历史桌上。 你们需要清楚解释每个工作单做些什么,你想找到下一个工作。

我假定,你正在使用所谓的“CurrRec New”,储存目前的行文。 你们想要把现在的一段放在历史桌上。 因此,就找到你的实际问题而言,你的法典应当这样看待:

    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
问题回答

暂无回答




相关问题
import of excel in SQL imports NULL lines

I have a stored procedure that imports differently formatted workbooks into a database table, does work on them then drops the table. Here is the populating query. SELECT IDENTITY(INT,1,1) AS ID ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

Excel date to Unix timestamp

Does anyone know how to convert an Excel date to a correct Unix timestamp?

C# GemBox Excel Import Error

I am trying to import an excel file into a data table using GemBox and I keep getting this error: Invalid data value when extracting to DataTable at SourceRowIndex: 1, and SourceColumnIndex: 1. As ...

Importing from excel "applications" using SSIS

I am looking for any tips or resources on importing from excel into a SQL database, but specifically when the information is NOT in column and row format. I am currently doing some pre-development ...

热门标签