From SelectionChange into UserForm

M

Mac

I've defined a UserForm in my worksheet and I also intercept the
Worksheet_SelectionChange; my question is - how do I get the Range variable
obtained via the Worksheet_SelectionChange method into the UserForm for
display? Tried adding a method to the form code and calling it with the Range
parameter from within Worksheet_SelectionChange, but this doesn't seem to
work ...
 
T

Tom Hutchins

One way...

In a VBA module (Insert >> Module in the Visual Basic Editor), define a
global Range variable:

Global CurrRng as Range

In the Worksheet_SelectionChange event code, assign the Target range value
to CurrRng:

Set CurrRng = Target

Your userform code can use CurrRng like any other variable. Before you close
the workbook, you should free the memory used by CurrRng:

Set CurrRng = Nothing

Hope this helps,

Hutch
 

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