Worksheet change event when changing cell data

andrewb90

Well-known Member
Joined
Dec 16, 2009
Messages
1,077
Hello all,

I am trying to do a worksheet change code, but can't quite get it right.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)    If H16 < -10 Then
    Columns("I:I").Hidden = False
    End If
End Sub

What I am trying to do is, when the value of H16 is changed, and it is less than -$10.00, then Column I will be unhidden. I only want that to happen when the value in H16 is changed, not when any cell is changed.

Any help would be greatly appreciated.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, [H16]) Is Nothing Then
    If [H16] < -10 Then [I1].EntireColumn.Hidden = False
End If
End Sub

Or if you want column I unhidden when H16 < -10 and hidden when = > -10 then :
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, [H16]) Is Nothing Then
    If [H16] < -10 Then
        [I1].EntireColumn.Hidden = False
    Else: [I1].EntireColumn.Hidden = True
    End If
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,900
Messages
6,175,276
Members
452,629
Latest member
SahilPolekar

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