navigating through rows using a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I created a form that adds a row to a spreadsheet, using an "Add New" button (thanks Tom Ogilvie!). I have not been able to figure out how to bind the three text boxes to their respective columns and navigate through the rows using either "Previous" and "Next" buttons, or the spin button control. I have used the range function to bind to a single cell, but can't make it work for the entire column. Any help would be greatly appreciated

Michael
 
No reason to "bind"

Private Sub btnPrevious_click()
if ActiveCell.Column <> 1 then
Cells(ActiveCell.row,1).Select
End if
if ActiveCell.row <> 1 then
ActiveCell.offset(-1,0).Select
Textbox1.Text = ActiveCell.Value
Textbox2.Text = ActiveCell.Offset(0,1).Value
Textbox3.Text = ActiveCell.offset(0,2).Value
end if
End sub

Private Sub btnNext_click()
Dim lastRow as Long
lastRow = Cells(rows.count,1).end(xlup)
if ActiveCell.Column <> 1 then
Cells(ActiveCell.row,1).Select
End if
if ActiveCell.row <> LastRow then
ActiveCell.offset(1,0).Select
Textbox1.Text = ActiveCell.Value
Textbox2.Text = ActiveCell.Offset(0,1).Value
Textbox3.Text = ActiveCell.offset(0,2).Value
end if
End sub

Would be a very basic approach.

--
Regards,
Tom Ogilvy



mdub said:
I created a form that adds a row to a spreadsheet, using an "Add New"
button (thanks Tom Ogilvie!). I have not been able to figure out how to
bind the three text boxes to their respective columns and navigate through
the rows using either "Previous" and "Next" buttons, or the spin button
control. I have used the range function to bind to a single cell, but can't
make it work for the entire column. Any help would be greatly appreciated!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top