PC Review


Reply
Thread Tools Rate Thread

Code to Delete Data in Specific Cells

 
 
Rich
Guest
Posts: n/a
 
      5th Aug 2009
Hi Everyone,

I was wondering if you could help me with some Excel Coding

The following is what I am trying to Achieve. Please note that I only want
it to happen on the Active Sheet, not on any of the other sheets

If P23 is updated, then clear the data in cells S23, T23, U23, V23, W23,
X23, Y23, Z23, AA23 or (S23:AA23)

If S23 is updated, then clear the data in cells V23, W23, X23, Y23, Z23,
AA23 or (V23:AA23)

If V23 is updated, then clear the data in cells X23, Y23, Z23, AA23 or
(X23:AA23)

If X23 is updated, then clear the data in cells Y23, Z23, AA23 or (X23:AA23)

I will actually want to apply this same function in rows 23 - 42 so if
there is some sort of short cut that applies the code to all rows that would
be great.
 
Reply With Quote
 
 
 
 
Per Jessen
Guest
Posts: n/a
 
      5th Aug 2009
Hi

This is an event code, so you have to paste it into the codesheet for the
desired sheet.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim TargetRow As Long
Application.EnableEvents = False
Set isect = Intersect(Target, Range("P23:P42"))
Set isect1 = Intersect(Target, Range("S23:S42"))
Set isect2 = Intersect(Target, Range("V23:V42"))
Set isect3 = Intersect(Target, Range("X23:X42"))

If Not isect Is Nothing Then
TargetRow = Target.Row
Range("S" & TargetRow & ":AA" & TargetRow).ClearContents
End If
If Not isect1 Is Nothing Then
TargetRow = Target.Row
Range("V" & TargetRow & ":AA" & TargetRow).ClearContents
End If
If Not isect2 Is Nothing Then
TargetRow = Target.Row
Range("X" & TargetRow & ":AA" & TargetRow).ClearContents
End If
If Not isect3 Is Nothing Then
TargetRow = Target.Row
Range("Y" & TargetRow & ":AA" & TargetRow).ClearContents
End If
Application.EnableEvents = True
End Sub

Hopes this helps.
....
Per

"Rich" <(E-Mail Removed)> skrev i meddelelsen
news:538B2101-FFA0-40ED-AB96-(E-Mail Removed)...
> Hi Everyone,
>
> I was wondering if you could help me with some Excel Coding
>
> The following is what I am trying to Achieve. Please note that I only want
> it to happen on the Active Sheet, not on any of the other sheets
>
> If P23 is updated, then clear the data in cells S23, T23, U23, V23, W23,
> X23, Y23, Z23, AA23 or (S23:AA23)
>
> If S23 is updated, then clear the data in cells V23, W23, X23, Y23, Z23,
> AA23 or (V23:AA23)
>
> If V23 is updated, then clear the data in cells X23, Y23, Z23, AA23 or
> (X23:AA23)
>
> If X23 is updated, then clear the data in cells Y23, Z23, AA23 or
> (X23:AA23)
>
> I will actually want to apply this same function in rows 23 - 42 so if
> there is some sort of short cut that applies the code to all rows that
> would
> be great.


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete cells containing specific data? =?Utf-8?B?TW9iaWxpdHkgR3V5?= Microsoft Excel Misc 1 22nd Mar 2007 08:29 PM
macro to select cells containing specific text and delete all cells but these JenIT Microsoft Excel Programming 3 27th Mar 2006 10:07 PM
how to delete contents of cells having specific data =?Utf-8?B?c3RldmU=?= Microsoft Excel Misc 2 20th Jul 2005 10:42 PM
Worksheet Change code not running when you just delete data in cells. KimberlyC Microsoft Excel Programming 0 23rd Jun 2005 01:43 AM
Delete specific cells contents in a row with some locked cells in the same row trussman Microsoft Excel Programming 2 1st Mar 2005 06:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:56 PM.