Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everybody,

I am working in VBA exercise using worksheet_change event,I was trying to change multiple cells in excel so that Change event should fire.But issue is, when I change single cell Change event gets fired ,not allowing to change multiple cells.I want to change multiple cells so that change event should fire.Can anyone plz guide me to solve this.
or

Anyotherway for getting changed cell value?


Thank You.
Posted
Updated 30-Nov-11 20:37pm
v2

hi, you can specify the ranges like the column or row so that once those set of cells can active the code you desire
VB
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    If Target.Column = 1 Then
        ThisRow = Target.Row
        If Target.Value > 100 Then
            Range("B" & ThisRow).Interior.ColorIndex = 3
        Else
            Range("B" & ThisRow).Interior.ColorIndex = xlColorIndexNone
        End If
    End If
End Sub

hope this helps
 
Share this answer
 
The Target parameter is a range object, it can cover multiple cells. To retrieve the values from the different cells:

Public Sub worksheet_change(ByVal target As Excel.Range)

Dim celCurr As Excel.Range

For Each celCurr In target.Cells
Debug.Print celCurr.Address, celCurr.value
Next celCurr

Set celCurr = Nothing

End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900