Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default SelectionChange userform

Hi all,

I've created a XLA that opens a form when I click a button in my toolbar.
This form displays a textbox containing the address of the activecell of the
activesheet.

I wonder how to get this textbox updated when I select another cell/range on
any other worksheets.

I guess I could use the Worksheet_SelectionChange event, but it will be
linked to the sheet inside my XLA, and thus won't be triggered if I select a
cell in an independant worksheet.

Any ideas ?

Thanks for any support,
Nicodemus

PS: this post might be triple as I'm not sure if the first one was published.
My apologize if it's the case.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default SelectionChange userform

Put this code in the ThisWorkbook module of the add-in and you will see.

Option Explicit
Private WithEvents xlApp As Excel.Application

Private Sub Workbook_Open()
Set xlApp = Excel.Application
End Sub

Private Sub xlApp_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)
MsgBox Target.Address
End Sub


RBS


"Nicodemus" wrote in message
...
Hi all,

I've created a XLA that opens a form when I click a button in my toolbar.
This form displays a textbox containing the address of the activecell of
the
activesheet.

I wonder how to get this textbox updated when I select another cell/range
on
any other worksheets.

I guess I could use the Worksheet_SelectionChange event, but it will be
linked to the sheet inside my XLA, and thus won't be triggered if I select
a
cell in an independant worksheet.

Any ideas ?

Thanks for any support,
Nicodemus

PS: this post might be triple as I'm not sure if the first one was
published.
My apologize if it's the case.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default SelectionChange userform

Hello RB,

it works fine indeed.
The problem is it keeps on working !
Even when I close my form. Is there a way to cancel or disable this function
when I quit the add-in ?

Thanks for your help
Nicodemus

"RB Smissaert" wrote:

Put this code in the ThisWorkbook module of the add-in and you will see.

Option Explicit
Private WithEvents xlApp As Excel.Application

Private Sub Workbook_Open()
Set xlApp = Excel.Application
End Sub

Private Sub xlApp_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)
MsgBox Target.Address
End Sub


RBS


"Nicodemus" wrote in message
...
Hi all,

I've created a XLA that opens a form when I click a button in my toolbar.
This form displays a textbox containing the address of the activecell of
the
activesheet.

I wonder how to get this textbox updated when I select another cell/range
on
any other worksheets.

I guess I could use the Worksheet_SelectionChange event, but it will be
linked to the sheet inside my XLA, and thus won't be triggered if I select
a
cell in an independant worksheet.

Any ideas ?

Thanks for any support,
Nicodemus

PS: this post might be triple as I'm not sure if the first one was
published.
My apologize if it's the case.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default SelectionChange userform

Yes, you could put the code in the userform:

Option Explicit
Private WithEvents xlApp As Excel.Application

Private Sub UserForm_Initialize()
Set xlApp = Excel.Application
End Sub

Private Sub xlApp_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)
MsgBox Target.Address
End Sub

Will have to be a modeless userform, otherwise you can't move in the sheet
while the form is loaded. Once the userform is unloaded it won't work
anymore.
The other option is to keep in the ThisWorkbook module, but make a toolbar
button that can turn this on and off via a public variable or by other
means.

RBS

"Nicodemus" wrote in message
...
Hello RB,

it works fine indeed.
The problem is it keeps on working !
Even when I close my form. Is there a way to cancel or disable this
function
when I quit the add-in ?

Thanks for your help
Nicodemus

"RB Smissaert" wrote:

Put this code in the ThisWorkbook module of the add-in and you will see.

Option Explicit
Private WithEvents xlApp As Excel.Application

Private Sub Workbook_Open()
Set xlApp = Excel.Application
End Sub

Private Sub xlApp_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)
MsgBox Target.Address
End Sub


RBS


"Nicodemus" wrote in message
...
Hi all,

I've created a XLA that opens a form when I click a button in my
toolbar.
This form displays a textbox containing the address of the activecell
of
the
activesheet.

I wonder how to get this textbox updated when I select another
cell/range
on
any other worksheets.

I guess I could use the Worksheet_SelectionChange event, but it will be
linked to the sheet inside my XLA, and thus won't be triggered if I
select
a
cell in an independant worksheet.

Any ideas ?

Thanks for any support,
Nicodemus

PS: this post might be triple as I'm not sure if the first one was
published.
My apologize if it's the case.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default SelectionChange userform

simply marvelous. It works perfectly now !

thank you very much for your help and your time
Nicodemus

"RB Smissaert" wrote:

Yes, you could put the code in the userform:

Option Explicit
Private WithEvents xlApp As Excel.Application

Private Sub UserForm_Initialize()
Set xlApp = Excel.Application
End Sub

Private Sub xlApp_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)
MsgBox Target.Address
End Sub

Will have to be a modeless userform, otherwise you can't move in the sheet
while the form is loaded. Once the userform is unloaded it won't work
anymore.
The other option is to keep in the ThisWorkbook module, but make a toolbar
button that can turn this on and off via a public variable or by other
means.

RBS

"Nicodemus" wrote in message
...
Hello RB,

it works fine indeed.
The problem is it keeps on working !
Even when I close my form. Is there a way to cancel or disable this
function
when I quit the add-in ?

Thanks for your help
Nicodemus

"RB Smissaert" wrote:

Put this code in the ThisWorkbook module of the add-in and you will see.

Option Explicit
Private WithEvents xlApp As Excel.Application

Private Sub Workbook_Open()
Set xlApp = Excel.Application
End Sub

Private Sub xlApp_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)
MsgBox Target.Address
End Sub


RBS


"Nicodemus" wrote in message
...
Hi all,

I've created a XLA that opens a form when I click a button in my
toolbar.
This form displays a textbox containing the address of the activecell
of
the
activesheet.

I wonder how to get this textbox updated when I select another
cell/range
on
any other worksheets.

I guess I could use the Worksheet_SelectionChange event, but it will be
linked to the sheet inside my XLA, and thus won't be triggered if I
select
a
cell in an independant worksheet.

Any ideas ?

Thanks for any support,
Nicodemus

PS: this post might be triple as I'm not sure if the first one was
published.
My apologize if it's the case.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default SelectionChange userform

No trouble; good to hear it works as needed.

RBS

"Nicodemus" wrote in message
...
simply marvelous. It works perfectly now !

thank you very much for your help and your time
Nicodemus

"RB Smissaert" wrote:

Yes, you could put the code in the userform:

Option Explicit
Private WithEvents xlApp As Excel.Application

Private Sub UserForm_Initialize()
Set xlApp = Excel.Application
End Sub

Private Sub xlApp_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)
MsgBox Target.Address
End Sub

Will have to be a modeless userform, otherwise you can't move in the
sheet
while the form is loaded. Once the userform is unloaded it won't work
anymore.
The other option is to keep in the ThisWorkbook module, but make a
toolbar
button that can turn this on and off via a public variable or by other
means.

RBS

"Nicodemus" wrote in message
...
Hello RB,

it works fine indeed.
The problem is it keeps on working !
Even when I close my form. Is there a way to cancel or disable this
function
when I quit the add-in ?

Thanks for your help
Nicodemus

"RB Smissaert" wrote:

Put this code in the ThisWorkbook module of the add-in and you will
see.

Option Explicit
Private WithEvents xlApp As Excel.Application

Private Sub Workbook_Open()
Set xlApp = Excel.Application
End Sub

Private Sub xlApp_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)
MsgBox Target.Address
End Sub


RBS


"Nicodemus" wrote in message
...
Hi all,

I've created a XLA that opens a form when I click a button in my
toolbar.
This form displays a textbox containing the address of the
activecell
of
the
activesheet.

I wonder how to get this textbox updated when I select another
cell/range
on
any other worksheets.

I guess I could use the Worksheet_SelectionChange event, but it will
be
linked to the sheet inside my XLA, and thus won't be triggered if I
select
a
cell in an independant worksheet.

Any ideas ?

Thanks for any support,
Nicodemus

PS: this post might be triple as I'm not sure if the first one was
published.
My apologize if it's the case.





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SelectionChange event Kate Excel Programming 2 December 22nd 05 06:03 PM
SelectionChange event Hayeso Excel Programming 2 July 1st 05 03:07 PM
SelectionChange problem Micher Excel Programming 0 January 23rd 04 10:26 PM
SelectionChange - What am I doing wrong? Doug[_9_] Excel Programming 4 January 2nd 04 02:46 AM
SelectionChange code always available René Excel Programming 0 July 13th 03 01:46 PM


All times are GMT +1. The time now is 04:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"