VBA delete cell in column I

Pinaceous

Well-known Member
Joined
Jun 11, 2014
Messages
1,113
Office Version
  1. 365
Platform
  1. Windows
Good Day,

I would like to create a vba code that if I delete a cell in Column I that it will clear the contents of its adjacent cell in Column H.

For example, if I delete the contents of Cell I11 the vba code will clear the contents of Cell H11.

Continuing ...
if I delete the contents of Cell I12 the vba code will clear the contents of Cell H12.

if I delete the contents of Cell I13 the vba code will clear the contents of Cell H13.

until ...

if I delete the contents of Cell I180 the vba code will clear the contents of Cell H180.

Please let me know if there is a sub code for this.

Thank you!
pinaceous
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
This is sheet code for the worksheet of interest. When you delete the contents of a cell in col I, the contents of the adjacent cell in col H will be cleared. The code is written to handle the case of multiple cells in col H being selected by the user and then being cleared simultaneously by the user pressing the Delete key.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
If Not Intersect(Target, Range("I:I")) Is Nothing Then
    For Each c In Intersect(Target, Range("I:I"))
        If IsEmpty(c) Then
            Application.EnableEvents = False
            c.Offset(0, -1).ClearContents
        End If
    Next c
End If
Application.EnableEvents = True
End Sub
 
Upvote 0
cell in Colum

This is sheet code for the worksheet of interest. When you delete the contents of a cell in col I, the contents of the adjacent cell in col H will be cleared. The code is written to handle the case of multiple cells in col H being selected by the user and then being cleared simultaneously by the user pressing the Delete key.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
If Not Intersect(Target, Range("I:I")) Is Nothing Then
    For Each c In Intersect(Target, Range("I:I"))
        If IsEmpty(c) Then
            Application.EnableEvents = False
            c.Offset(0, -1).ClearContents
        End If
    Next c
End If
Application.EnableEvents = True
End Sub


Thanks

JoeMo!​

 
Upvote 0

Forum statistics

Threads
1,214,972
Messages
6,122,530
Members
449,088
Latest member
RandomExceller01

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