Worksheet_change Method

M

Michael

Hi all,

Is it possible to expand the code below to apply it a
range of cells. At present it only works on a single cell
D13 and consequently C13.Is this possible?,

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address <> "$D$13" Then Exit Sub
[c13].Value = Target
Range("C13").Select
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
End With
Selection.Font.Bold = True
End Sub

Thanks for your help

Michael
 
R

Ron de Bruin

Hi Michael

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Application.Intersect(Range("a1:a20"), Target) Is Nothing Then
MsgBox "Hi"
End If
End Sub

You can do this for a range
This will show the Msgbox if you change a cell in the range a1:a20

This will show the Msgbox if you change a othere cell then one from the range a1:a20

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Application.Intersect(Range("a1:a20"), Target) Is Nothing Then
MsgBox "Hi"
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top