Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default how can vba detect what is currently selected?

hi,

i have a userform which i use to create the formulae for dynamic ranges.
when it initializes, it bases itself on the currently selected cell, which
works fine. however, i noticed the other day that if some other object is
selected (in this case, a chart) the VBA returns an error.

how can i determine what sort of thing is selected when the form is
initialized? the user form uses a RefEdit control (I know, I know!), so i
wouldn't really want the form to close, as the user would have the chance to
select a range whilst the form is still open.

tia,

Tim


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default how can vba detect what is currently selected?

Roedd <<Tim Marsh wedi ysgrifennu:

hi,

i have a userform which i use to create the formulae for dynamic
ranges. when it initializes, it bases itself on the currently
selected cell, which works fine. however, i noticed the other day
that if some other object is selected (in this case, a chart) the VBA
returns an error.

how can i determine what sort of thing is selected when the form is
initialized? the user form uses a RefEdit control (I know, I know!),
so i wouldn't really want the form to close, as the user would have
the chance to select a range whilst the form is still open.


if typeof selection is Excel.Range then
' Load address into refedit
else
' Do whatever
end if

HTH

Rob


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default how can vba detect what is currently selected?

Thanks Rob - never used 'typeof' before, but it seems to do the trick
nicely!

cheers

tim

"Robert Bruce" <rob@analytical-dynamicsdotcodotukay wrote in message
...
Roedd <<Tim Marsh wedi ysgrifennu:

hi,

i have a userform which i use to create the formulae for dynamic
ranges. when it initializes, it bases itself on the currently
selected cell, which works fine. however, i noticed the other day
that if some other object is selected (in this case, a chart) the VBA
returns an error.

how can i determine what sort of thing is selected when the form is
initialized? the user form uses a RefEdit control (I know, I know!),
so i wouldn't really want the form to close, as the user would have
the chance to select a range whilst the form is still open.


if typeof selection is Excel.Range then
' Load address into refedit
else
' Do whatever
end if

HTH

Rob




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
Multiple cells or columns are selected instead of selected cell or Mikey Excel Discussion (Misc queries) 1 April 29th 09 09:48 PM
How to detect row number of selected cells? Ivan Excel Programming 1 May 9th 06 05:43 AM
how do i make it so that when a sheat is selected either via link or tab, that xlLastCell is selected. the last on the sheet. Daniel Excel Worksheet Functions 1 July 12th 05 01:30 AM
Detect selected chart point Mark Excel Programming 1 March 31st 05 12:23 AM
Detect if a selected cell is within a named range CraigB Excel Programming 2 November 25th 04 03:44 PM


All times are GMT +1. The time now is 10:34 AM.

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"