Worksheet_change event multiple

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I wanted to test data input on more than one cell. Trying to enter more than
one worksheet_change returns the "ambiguous name" error (same sub name). I
realize that I can do all my IF tests and code calls under the one
Worksheet_change event but it gets crowded.
Is it the only way ?

Thanks for any help and education.
jeffp
 
You can only habe one worksheet_change event per worksheet. This is the only
way to do it. what you could do is split up the if..elseif..else...end if
from the actual implementation code - something like

Private Sub Worksheet_Change(ByVal Target As Range)

if target.column = 1 then
call DoStuffToColumn1(target)
elseif target.column = 2 then
call DoStuffToColumn2(target)
else
...do whatever
end if

End Sub

private function DoStuffToColumn1(Target as excel.range)
....write code here
end function

private function DoStuffToColumn2(Target as excel.range)
....write code here
end function
 

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