How can I call a Excel Macro from VB?

  • Thread starter Thread starter Kenji
  • Start date Start date
K

Kenji

I would like to open an excel sheet and enter a value in a cell then call an
macro. Is this possible to do with VB? Thanks in advance!

Kenji
 
Hi
you may use an event macro for this. In this case the worksheet_change
event would do. Put the following code in your worksheet module (not in
a standard module):

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.count > 1 Then Exit Sub
If Intersect(Target, Me.Range("A1:A10")) Is Nothing Then Exit Sub
With Target
if .value <>"" then
msgbox "Value entered in cell" & .address
end if
End With
End Sub
 
Back
Top