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

  • Thread starter Thread starter mariusfink
  • Start date Start date
M

mariusfink

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
 
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
 

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