Can you use "Target" in a Module besides the worksheet module

K

kylekelsch

I'm making an order entry program and Im wondering if there is a way
to refer to the target in any module, not just the worksheet module
 
D

Dave Peterson

I think what you want is to pass the target to that other routine?

You'll still need that worksheet (workbook?) event to call that routine, though.

For instance, I used this code behind the worksheet:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Call myOtherSub(Target.Cells(1))
End Sub

And this code in a General module:
Option Explicit
Sub myOtherSub(myCell As Range)
MsgBox myCell.Address(0, 0)
End Sub

Whenever I change anything in the worksheet, I pass the first cell in the
changed range to the myOtherSub routine.
 
K

kylekelsch

thanks Dave I've looked all over trying to find a good why to do that
and could't find anything. Your suggestion worked perfect.
 

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