Advertisement

06.24.2008 at 09:40AM PDT, ID: 23511653
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.9

specialcells triggers selection change.  how can selectionchange detect this abomination?

Asked by rberke in Microsoft Excel Spreadsheet Software

This has been modified since I originally posted it.  The new comments are at the end.

I have just discovered that specialcells sometimes triggers the selectionchange routine.  

This is really screwy and causing me problems.  I have maybe 100 macros that use specialcells, and I don't want them all to go bonkers when my addin is active.

Nor do I want to go to all 100 routines and add .enableevents = false then reset back to true after specialcells

I think the following workaround is OK. it seems to solve my problems, but I am worried that there might be some obscure details I am missing.

Can anybody enlighten me on this issue? I am only looking for general guidelines, so I am intentionally not giving much detail about my addin.
For instance, under what other conditions might target.address not be the same as selection.address???

sub  MyApplication_SheetSelectionChange(ByVal Sh As Object, ByVal target As Range)
' see http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_23511653.html
if typename(target) is nothing then exit sub  ' <==== the typname is just in case the selected cells  have all been deleted
' the following is just in case the selectionchange routine gets called by specialcells or similar abominations
Dim cntWeird As Long
If Intersect(ActiveCell, target) Is Nothing Then cntWeird = cntWeird + 1
If target.Address <> Selection.Address Then cntWeird = cntWeird + 1
If cntWeird = 1 Then MsgBox "If both tests are equivalent this msgbox will never happen"
If cntWeird = 2 Then Exit Sub

rberke

P.S.  I searched the internet and didn't come up with much that was useful.  For instance http://www.vbaexpress.com/forum/showthread.php?p=132469  discussed similar problems, and never reached a conclusion.

New comment #1. I manually drag cell a1 and copy it onto a1:a15.  then I do an undo.  The Target is a1:a15 which is weird, but the Selection is a1 which is what I would expect.  In all my past experience with SelectionChange, I coded the modules to reference Target.  I now wonder whether I should have referenced Selection instead?

New comment #2. sheet1.Cells.PasteSpecial xlPasteValuesAndNumberFormats
 causes selectionchange to get target = $1:$65536 and selection =$A$1:$CP$21.  I guess  that makes sense.  The "target" is sheet1.cells which has the ENTIRE workbook.  Maybe in a few more days I will understand this better.
Start Free Trial
[+][-]06.26.2008 at 11:03AM PDT, ID: 21877361

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Excel Spreadsheet Software
Sign Up Now!
Solution Provided By: zorvek
Participating Experts: 1
Solution Grade: A
 
 
[+][-]06.26.2008 at 01:06PM PDT, ID: 21878494

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.26.2008 at 01:11PM PDT, ID: 21878548

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.26.2008 at 01:14PM PDT, ID: 21878575

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.26.2008 at 01:21PM PDT, ID: 21878636

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.26.2008 at 01:28PM PDT, ID: 21878702

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.14.2008 at 05:57PM PDT, ID: 22003425

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.14.2008 at 06:57PM PDT, ID: 22003656

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628