View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
RJQMAN[_2_] RJQMAN[_2_] is offline
external usenet poster
 
Posts: 54
Default Should I activate workbook before activating sheet when button is selected?

I had two Excel programs open on my desktop, and I was working with
one, and then jumped to the other, pressing a Command Button on the
2nd program. The 2nd program crashed, as the macro tried to operate
on the first program.

I send this program out for 'soccer moms' to use to keep score at
competitive high school events, so I want it to be as foolproof as
possible. The first event of the season is in eight days.

I realized right away what had taken place, but the users of my
program probably will not and would just see the program display jump
over into the VBA section and not know what to do. In order to
prevent them from having this experience and going into a state of
panic, how can I best prevent the problem from happening to them?
Should I insert a statement at the start of my macros to active the
workbook each time? That would be easy enough to do, but I am not
sure if it would be the best approach, or how to word it so that it
does not cause a problem greater than the one it is supposed to solve.

If my macros apply to another page in the workbook, they already say
'thiswookbook.sheets(" at the beginning. If they apply to the sheet
that is open, they all presently start with 'activesheet'/

Should I modify that statement somehow, or should I have some kind of
'activate workbook' statement first, in case they do what I did - work
on one spreadsheet, and then jump over and click a button on my
program?

I appreciate the advice very much.