View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Sam Wilson Sam Wilson is offline
external usenet poster
 
Posts: 523
Default Replace cell values in multiple columns

Assuming you have "All States" in column A, right click your tab and view
code and then paste this in:

Private Sub Worksheet_Change(ByVal Target As Range)

Dim i As Integer

If Not Intersect(Target, Columns("A:A")) Is Nothing And Target.Value = 1 Then
For i = 1 To 50
Target.Offset(0, i).Value = 0
Next i
End If

End Sub

"Jen_T" wrote:

I have a worksheet that has 51 columns, each column is a state label, that
shows a status of "1" or "0". This includes is a column that indicates "ALL
STATES". I am looking to see how to write a macro that would look at "All
States" (column M) and if "1" than look in same row for each state and
replace if remaining states are equal to "1" (1- 50) to a "0"
Then do this for each row.
Example:
ALL STATES AK AL CA CO CT
1 1 1 0 1 0

Final Results
ALL STATES AK AL CA CO CT
1 0 0 0 0 0

Not sure how to write this in code.