Selecting the next row up or down??????

B

Bob

I have a userform with several textboxes which I fill in data and save to a
data sheet. It also has a search facility by inserting a date in textbox1 and
pressing a commandbutton, it brings up data from that row.
I am trying to find a way to select the next row up or down and have the
data display. So that I can select a date and have the data displayed then go
up or down the rows from that date.
 
G

Gary''s Student

To select the next row down from where you are:

Sub OneRowDown()
ActiveCell.Offset(1, 0).EntireRow.Select
End Sub
 
B

Bob

Thanks Gary that works but I need it to select the data on that row from
sheet2.
I have the following code so far (without your code in). The data is found
on sheet2

Private Sub CommandButton4_Click()
Dim FoundCell As Range

ActiveCell.Offset(-1, 0).Select

If FoundCell Is Nothing Then
'this shouldn't happen!
Beep
Else
Me.TextBox1.Value = FoundCell.Offset(0, 1).Value
Me.ComboBox1.Value = FoundCell.Offset(0, 1).Value
Me.TextBox2.Value = FoundCell.Offset(0, 2).Value

If IsDate(FoundCell.Offset(0, 0).Value) Then
Me.TextBox1.Value = Format(FoundCell.Offset(0, 0).Value, "dd-mmm-yy")
Else
Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
End If
End If
End Sub

any ideas?
 

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

Top