ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Programming a 'frozen' cell (https://www.excelbanter.com/excel-programming/374143-programming-frozen-cell.html)

Paddler

Programming a 'frozen' cell
 
I have a budget spreadsheet : cell B4 says 'REVENUES' and cell B20 says
'EXPENSES'. That's fine when I print the spreadsheet.

For onscreen viewing, I 'freeze' rows A:1 thru A:8.

When the screen scrolls to row 21, I want cell B4 to say 'EXPENSES'.

What IF statement or macro code will switch the dispaly in cell B4 when I
'freeze' the titles.

Jim Thomlinson

Programming a 'frozen' cell
 
Scrolling in and of itself does not generate an event. The closes you will
get is the selection change event so that when a cell is selected the value
will change based on the row number, something like this...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row < 21 Then
Range("B4").Value = "Revenues"
Else
Range("B4").Value = "Expenses"
End If
End Sub
--
HTH...

Jim Thomlinson


"Paddler" wrote:

I have a budget spreadsheet : cell B4 says 'REVENUES' and cell B20 says
'EXPENSES'. That's fine when I print the spreadsheet.

For onscreen viewing, I 'freeze' rows A:1 thru A:8.

When the screen scrolls to row 21, I want cell B4 to say 'EXPENSES'.

What IF statement or macro code will switch the dispaly in cell B4 when I
'freeze' the titles.


Paddler

Programming a 'frozen' cell
 
Jim
Yes it works 'but'.

I have 23 sheets in this budget workbook. Is there one place to put the
code so it works on all sheets or do I insert your code in each worksheets
code page?

Excel VBA is foreign to me but I do some Access VBA. Access has "On Mouse
Down" event. Could this event in Excel be used to change the cell B4 display?

Paddler

"Jim Thomlinson" wrote:

Scrolling in and of itself does not generate an event. The closes you will
get is the selection change event so that when a cell is selected the value
will change based on the row number, something like this...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row < 21 Then
Range("B4").Value = "Revenues"
Else
Range("B4").Value = "Expenses"
End If
End Sub
--
HTH...

Jim Thomlinson


"Paddler" wrote:

I have a budget spreadsheet : cell B4 says 'REVENUES' and cell B20 says
'EXPENSES'. That's fine when I print the spreadsheet.

For onscreen viewing, I 'freeze' rows A:1 thru A:8.

When the screen scrolls to row 21, I want cell B4 to say 'EXPENSES'.

What IF statement or macro code will switch the dispaly in cell B4 when I
'freeze' the titles.



All times are GMT +1. The time now is 02:33 PM.

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