Go to a cell that contains the data entered in another cell

  • Thread starter Thread starter QD
  • Start date Start date
Q

QD

I need help!

I have a spreadsheet with a calendar for all dates in a year. Total
four pages long. Now I am trying to create a Command button that will
help me find todays date or the date that I enter in a cell that I
want to go to, simply by entering date and clicking the command
button. Or enter the date that I am looking for in a cell and hit
enter. It will scroll upto that date in the spreasheet.

Thanks
 
Let's say that in A1 thru A365 we have 1/1/2008 thru 12/31/2008. In the
worksheet code area paste:

Private Sub Worksheet_Change(ByVal Target As Range)
Set r = Range("B1")
If Intersect(Target, r) Is Nothing Then Exit Sub
v = r.Value
For i = 1 To 365
If Cells(i, 1) = v Then
Cells(i, 1).Select
Exit Sub
End If
Next
End Sub

Enter a date in cell B1 and you will scroll to that date in A1.
 
Let's say that in A1 thru A365 we have 1/1/2008 thru 12/31/2008.  In the
worksheet code area paste:

Private Sub Worksheet_Change(ByVal Target As Range)
Set r = Range("B1")
If Intersect(Target, r) Is Nothing Then Exit Sub
v = r.Value
For i = 1 To 365
    If Cells(i, 1) = v Then
        Cells(i, 1).Select
        Exit Sub
    End If
Next
End Sub

Enter a date in cell B1 and you will scroll to that date in A1.
--
Gary''s Student - gsnu2007d







- Show quoted text -



Gary's Student,

You are a genious!!

Thanks a bunch. This works great if the dates in one column. I have
set it up as a calendar by month. What I need to do to get the code to
work. January
SUN MON TUE WED THU FRI SAT
01/01/2008 01/02/2008 01/03/2008
01/04/2008 01/04/2008
01/05/2008 and so on.

Thanks a million!!!
 
Gary,
Would it also be possible to get the target cell to scroll all the way
to the top left corner of the screen, eg to "B2"'s position? Thanks
 

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