NOT ABLE TO ENTER VB CODE

  • Thread starter Thread starter SANDIND
  • Start date Start date
S

SANDIND

I am not able to enter this " Private Sub Worksheet_Change(ByVal Target As
Range" more than once in the sheet code of any particular code.

Once I am entering any macro starting with this it says ambiguos code, I am
new to VB kindly help me out.

Thanks
 
Hi,

What you are entering is called event code and the event
Private Sub Worksheet_Change...
is executed whenver the worksheet changes but you can only have one module
with this name. You could try something like this

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
'do something
End If

If Target.Address = "$B$1" Then
'do something else
End If
End Sub


Mike
 

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

Back
Top