close

For example, I freeze pane for row 1, and want A1 cell to display quot;Text1quot;
when windows is scrolling within row 2~100, and display quot;Text2quot; when it's
scrolled beyond row 101, can I use such formula in A1:

=if(GetCurrentTopRow() lt; 100, quot;Text1quot;, quot;Text2quot;)

is there such a function?

use =ROW() to get the row number
--
Gary's Studentquot;ryanyquot; wrote:

gt; For example, I freeze pane for row 1, and want A1 cell to display quot;Text1quot;
gt; when windows is scrolling within row 2~100, and display quot;Text2quot; when it's
gt; scrolled beyond row 101, can I use such formula in A1:
gt;
gt; =if(GetCurrentTopRow() lt; 100, quot;Text1quot;, quot;Text2quot;)
gt;
gt; is there such a function?

Hi ryany,
I don't know of any way of achieving this without using an event
procedure.

The following Worksheet_SelectionChange Sub pasted into the code module
of the worksheet works.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveWindow.ScrollRow lt; 101 Then
Let Range(quot;A1quot;).Value = quot;Text1quot;
Else: Let Range(quot;A1quot;).Value = quot;Text2quot;
End If
End Sub

To get the code in place follow the following steps:

1.Copy the above code
2.Right Click the worksheet tab then select quot;View codequot; from the
contextual popup menu.
3.Paste the code into the blank code module.
4.Edit the quot;Text1quot; and quot;Text2quot; strings.
5.Return to Excel worksheet by pressing Alt F11 or going Filegt;Close
and Return to Microsoft Excel.

Ken Johnson

全站熱搜
創作者介紹
創作者 software 的頭像
software

software

software 發表在 痞客邦 留言(0) 人氣()