ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   scroll rows up or down (https://www.excelbanter.com/excel-programming/345106-scroll-rows-up-down.html)

Rick

scroll rows up or down
 
I am using this code to find the current cell that matches the current date.
All works fine except I want to also have the current cell go to the top of
the window under the frozen headings. How can I alter the code to do this.

Dim SubStr
Dim MyCell As Range
Dim NextRow As Range
Sheets("Food").Select
Cells.Select
Selection.Columns.AutoFit
Range("A2:E2").Select
SubStr = Date
Call NxtRow(SubStr, MyCell, NextRow)
NextRow.Select
End Sub
Sub NxtRow(SubStr, MyCell, NextRow)
'
Cells.Select
Set MyCell = ActiveSheet.Range("A4")
Do
If MyCell.Value = "" Then
Exit Do
ElseIf MyCell.Value = SubStr Then
Set NextRow = MyCell
Exit Do
Else
Set MyCell = MyCell.Offset(1, 0)
End If
Loop
End Sub
--
Rick Rack

chijanzen

scroll rows up or down
 
Rick:

Call NxtRow(SubStr, MyCell, NextRow)
Application.Goto Reference:=NextRow, scroll:=True

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Rick" wrote:

I am using this code to find the current cell that matches the current date.
All works fine except I want to also have the current cell go to the top of
the window under the frozen headings. How can I alter the code to do this.

Dim SubStr
Dim MyCell As Range
Dim NextRow As Range
Sheets("Food").Select
Cells.Select
Selection.Columns.AutoFit
Range("A2:E2").Select
SubStr = Date
Call NxtRow(SubStr, MyCell, NextRow)
NextRow.Select
End Sub
Sub NxtRow(SubStr, MyCell, NextRow)
'
Cells.Select
Set MyCell = ActiveSheet.Range("A4")
Do
If MyCell.Value = "" Then
Exit Do
ElseIf MyCell.Value = SubStr Then
Set NextRow = MyCell
Exit Do
Else
Set MyCell = MyCell.Offset(1, 0)
End If
Loop
End Sub
--
Rick Rack


Rick

scroll rows up or down
 
Thanks it worked perfect.
--
Rick Rack


"chijanzen" wrote:

Rick:

Call NxtRow(SubStr, MyCell, NextRow)
Application.Goto Reference:=NextRow, scroll:=True

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Rick" wrote:

I am using this code to find the current cell that matches the current date.
All works fine except I want to also have the current cell go to the top of
the window under the frozen headings. How can I alter the code to do this.

Dim SubStr
Dim MyCell As Range
Dim NextRow As Range
Sheets("Food").Select
Cells.Select
Selection.Columns.AutoFit
Range("A2:E2").Select
SubStr = Date
Call NxtRow(SubStr, MyCell, NextRow)
NextRow.Select
End Sub
Sub NxtRow(SubStr, MyCell, NextRow)
'
Cells.Select
Set MyCell = ActiveSheet.Range("A4")
Do
If MyCell.Value = "" Then
Exit Do
ElseIf MyCell.Value = SubStr Then
Set NextRow = MyCell
Exit Do
Else
Set MyCell = MyCell.Offset(1, 0)
End If
Loop
End Sub
--
Rick Rack



All times are GMT +1. The time now is 07:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com