ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can you use "Target" in a Module besides the worksheet module (https://www.excelbanter.com/excel-programming/382250-can-you-use-target-module-besides-worksheet-module.html)

[email protected]

Can you use "Target" in a Module besides the worksheet module
 
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


Dave Peterson

Can you use "Target" in a Module besides the worksheet module
 
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.


wrote:

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


--

Dave Peterson

[email protected]

Can you use "Target" in a Module besides the worksheet module
 
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.



All times are GMT +1. The time now is 09:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com