PDA

View Full Version : I Need vba code clear cells



etheer
02-02-2013, 01:44 PM
Hello
I Need Code Delete Yes And Number From Cells In Column L And K When Change Cell J7 To Yes

etheer
02-02-2013, 02:09 PM
I get this code
I need code work when change J7 to yes

Private Sub CommandButton1_Click()
Range("K7:K180,L7:L180").ClearContents
End Sub

Please help me

etheer
03-28-2013, 07:55 PM
Hi
i get this code work very good


Sub clean()
Range("K7:K180,L7:L180,AI7:AI180,AJ7:AJ180,AK7:AK180,AL7:AL180,AM7:AM180,AN7:AN180 ,AO7:AO180").ClearContents

End Sub

how to edit it to work in 2 sheet
name sheet1 ACCOUNT
name sheet2 ACCOUNT2
i need code clear sheet1 and sheet2

sassora
03-28-2013, 11:26 PM
Sheets("ACCOUNT").Range("K7:L180,AI7:AO180").ClearContents
Sheets("ACCOUNT2").Range("K7:L180,AI7:AO180").ClearContents

mdmackillop
03-29-2013, 08:28 AM
This is a Worksheet Event code and goes in the Worksheet Module for the sheet which contains your J7 cell

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub

On Error GoTo Exits
Application.EnableEvents = False
If Target.Address = "$J$7" And UCase(Target) = "YES" Then
Sheets("ACCOUNT").Range("K7:K180,L7:L180").ClearContents
Sheets("ACCOUNT2").Range("K7:K180,L7:L180").ClearContents
End If
Exits:
Application.EnableEvents = True
End Sub

etheer
03-29-2013, 07:02 PM
Sheets("ACCOUNT").Range("K7:L180,AI7:AO180").ClearContents
Sheets("ACCOUNT2").Range("K7:L180,AI7:AO180").ClearContents

Thank you code work 100%

etheer
03-29-2013, 07:03 PM
This is a Worksheet Event code and goes in the Worksheet Module for the sheet which contains your J7 cell

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub

On Error GoTo Exits
Application.EnableEvents = False
If Target.Address = "$J$7" And UCase(Target) = "YES" Then
Sheets("ACCOUNT").Range("K7:K180,L7:L180").ClearContents
Sheets("ACCOUNT2").Range("K7:K180,L7:L180").ClearContents
End If
Exits:
Application.EnableEvents = True
End Sub
Thank you code work 100%