ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If cell is changed clear all cells to the right in that row (https://www.excelbanter.com/excel-programming/387791-if-cell-changed-clear-all-cells-right-row.html)

Sonic

If cell is changed clear all cells to the right in that row
 
I need to be able to automatic clear all cells to the right of the cell that
was changed. If anyone can help Thanks in advance.

David McRitchie

If cell is changed clear all cells to the right in that row
 
Try recording a macro then convert that to a
Change Event macro.
Event Macros, Worksheet Events and Workbook Events
http://www.mvps.org/dmcritchie/excel/event.htm

Here is something to play with, install
by right clicking on the sheet tab the insert following code

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.row = 1 Then Exit Sub
If Target.Cells.Count 1 Then Exit Sub

On Error GoTo ErrHandler
Application.EnableEvents = False
If Target.Column 1 Then
Range(Target.Offset(0, 1), Target.Offset(0, _
Cells.SpecialCells(xlLastCell).Column _
- Target.Column)).Select

If Target.Offset(0, 1).Interior.ColorIndex = 6 Then
Selection.Interior.ColorIndex = 20
Selection.Interior.Pattern = xlSolid
Else
Selection.Interior.ColorIndex = 6
Selection.Interior.Pattern = xlSolid
End If
' Selection.Clear
End If
ErrHandler:
Application.EnableEvents = True
End Sub

---
HTH,
David McRitchie, Microsoft MVP - Excel
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Sonic" wrote ...
I need to be able to automatic clear all cells to the right of the cell that
was changed. If anyone can help Thanks in advance.





All times are GMT +1. The time now is 05:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com