ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Event Programming - Cell Value change - 2 sheets involved - VBA - Excel (https://www.excelbanter.com/excel-programming/382936-event-programming-cell-value-change-2-sheets-involved-vba-excel.html)

[email protected]

Event Programming - Cell Value change - 2 sheets involved - VBA - Excel
 
Hi,

I got an excel file consisting of 3 sheets.

I want to hide rows 53 to 88 in the last sheet called "Expense Report"
whenever there is a value (letters) entered in cell C6 in the sheet
"General Info".

I know I need a Worksheet_SelectionChange event and this is what I
came up with. However it does not work. This is what I programmed:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Sheets("General Info").Select
APPILCATION.Goto C6
If (ActiveCell.Value 0) Then
Sheets("Expense Report").Select
Range("53:88").EntireRow.Hidden = True
Else
Range("53:88").EntireRow.Hidden = FALSE
End If
End Sub

Any help?

Where do I need to put the code when I open the VBA-editor?

Regards


Charles Chickering

Event Programming - Cell Value change - 2 sheets involved - VBA -
 
Try putting this in the sheet code for "General Info"
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) < "C6" Then Exit Sub
If Target 0 Then
Worksheets("Expense Report").Range("A53:A88").EntireRow.Hidden = True
Else
Worksheets("Expense Report").Range("A53:A88").EntireRow.Hidden = False
End If
End Sub
--
Charles Chickering

"A good example is twice the value of good advice."


" wrote:

Hi,

I got an excel file consisting of 3 sheets.

I want to hide rows 53 to 88 in the last sheet called "Expense Report"
whenever there is a value (letters) entered in cell C6 in the sheet
"General Info".

I know I need a Worksheet_SelectionChange event and this is what I
came up with. However it does not work. This is what I programmed:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Sheets("General Info").Select
APPILCATION.Goto C6
If (ActiveCell.Value 0) Then
Sheets("Expense Report").Select
Range("53:88").EntireRow.Hidden = True
Else
Range("53:88").EntireRow.Hidden = FALSE
End If
End Sub

Any help?

Where do I need to put the code when I open the VBA-editor?

Regards




All times are GMT +1. The time now is 08:01 AM.

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