Forum Discussion
Deleted
Feb 04, 2026VBA Code "Next" button. Should be so simple...
I have the following codes in the click event for a "next" and "prev" buttons on my userform. The prev button works fine, the next button will not advance to the next record in my table, and instead ...
Olufemi7
Feb 10, 2026Iron Contributor
Hello Deleted​,
LastRow is never set, so VBA treats it as 0, making If CurrentRow < LastRow always false.
Assign LastRow first, for example in UserForm_Initialize with LastRow = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row. Numeric variables default to 0 in VBA.