Why is my code now working?

MariPip

New Member
Joined
Jul 16, 2014
Messages
29
So I have come up with this really simple code
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Me.Range("I") Then
If Sheet("CAPA").Cells("G9").Value = "" Then
Target.Hidden = True
Else
Target.Hidden = False
End If
End If
End Sub

And It is not working, can anyone help me fix it????
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Target.Address requires a string, a cell reference such as "$A$1"

so

If Target.Address = "$A$1" Then
 
Upvote 0
If you are just wanting to hide Column I if cell G9 is empty, you can use...

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Columns("I").Hidden = Range("G9").Value = ""
End Sub
 
Upvote 0
I'm writing this code on the Worksheet that contains G9, and I wish to hide row I from another worksheet called RESUMO... What changes should I make to the code?
If you are just wanting to hide Column I if cell G9 is empty, you can use...

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Columns("I").Hidden = Range("G9").Value = ""
End Sub
 
Upvote 0
Try...

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Sheets("RESUMO").Columns("I").Hidden = Range("G9").Value = ""
End Sub
 
Upvote 0

Forum statistics

Threads
1,222,827
Messages
6,168,482
Members
452,192
Latest member
FengXue

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top