I have two issues with CmdNext and CmdInsert buttons respectively
1. going at the last record or last used row. After pressing Next_button with display of lastusedrow i.e after pressing Next after the Last record or lastrowused
A) it goes to First row. How can i prevent it ?
B) and also it should not got to next row after the last row
2. When Inserting a blank row at any row. I am not able to further see records when pressing next button
for eg at row 6 i insert a blank row and then i press next button able to see 7th row details but not able to see records of 8, 9, 10 records.
Why is so that this is preventing to move further?
will appreciate your help by mentioning respective issue nos with its sub(s) too.
Thanks
NimishK
1. going at the last record or last used row. After pressing Next_button with display of lastusedrow i.e after pressing Next after the Last record or lastrowused
A) it goes to First row. How can i prevent it ?
B) and also it should not got to next row after the last row
2. When Inserting a blank row at any row. I am not able to further see records when pressing next button
for eg at row 6 i insert a blank row and then i press next button able to see 7th row details but not able to see records of 8, 9, 10 records.
Why is so that this is preventing to move further?
will appreciate your help by mentioning respective issue nos with its sub(s) too.
Code:
Private Sub UserForm_Initialize()
Dim lastUsedRow As Long
curRec = 1
curRow = 2
End Sub
Private Sub CmdNext_Click()
Dim idWs As Worksheet
With Worksheets(Sheet1)
LastUsedRow = .Cells(Rows.Count, 1).End(xlUp).Row
If curRec < LastUsedRow Then
curRec = curRec + 1
curRow = curRow + 1
uf1.txtData1.Text = .Cells(curRow, 1).Value
uf1.txtData2.Text = .Cells(curRow, 2).Value
End if
End With
End Sub
Private Sub cmdInsert_Click()
Dim idWs As Worksheet
With Worksheets(Sheet1)
Rows(curRow).Select
Selection.EntireRow.Insert
End With
End Sub
NimishK
Last edited: