How can I call a Excel Macro from VB?

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
 
F

Frank Kabel

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
 

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