Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Selecting all sheets and sheet methods

I've got some code in a spreadsheet that will be called when the user tries
to insert a sheet, so that any sheet inserted already has the formatting and
other hidden ranges needed inside it. Part of this process involves
unprotecting the current activesheet, making some changes, then reprotecting
it.

The activesheet object seems to be accessible programitcally when all sheets
have been selected - at least in regards to retreiving property values - but
falls over when the unprotect and protect methods are called.

The user shouldn't really be selecting multiple sheets but they shouldn't be
seeing such errors either. Is there any way of checking to see if multiple
sheets have been selected from within VBA code within the spreadsheet?
Activesheet doean't seem to provide me with any useful information and I
would prefer to avoid calling any methods to check to see if any errors are
returned.

I'm currently using Excel 2003, but the solution would have to work in Excel
97 too.

---
Patrick Seurre
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Selecting all sheets and sheet methods

I don;t know of a way to figure out how many sheets are selected at any 1 time.

I would advise this though.

Find out the error number that Excel is throwing at you and then at the
beginning of your code do this....

On error Goto ErrorHandler

ErrorHandler:

If Err.Num = [Error Number} then

MsgBox "More than 1 sheet is selected. Please try again!"
End Sub

End If

A quick and easy answer to get around the problem by making the user aware.

HTH

"Patrick Seurre" wrote:

I've got some code in a spreadsheet that will be called when the user tries
to insert a sheet, so that any sheet inserted already has the formatting and
other hidden ranges needed inside it. Part of this process involves
unprotecting the current activesheet, making some changes, then reprotecting
it.

The activesheet object seems to be accessible programitcally when all sheets
have been selected - at least in regards to retreiving property values - but
falls over when the unprotect and protect methods are called.

The user shouldn't really be selecting multiple sheets but they shouldn't be
seeing such errors either. Is there any way of checking to see if multiple
sheets have been selected from within VBA code within the spreadsheet?
Activesheet doean't seem to provide me with any useful information and I
would prefer to avoid calling any methods to check to see if any errors are
returned.

I'm currently using Excel 2003, but the solution would have to work in Excel
97 too.

---
Patrick Seurre

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Selecting all sheets and sheet methods

Hi Patrick,

Maybe

If Activeworkbook.windows(1).SelectedSheets.count 1 Then
MsgBox "oops!"
End If

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Patrick Seurre" <msdn_newsgroups001@_removetextplusunderscores_seu rre.com.
wrote in message ...
I've got some code in a spreadsheet that will be called when the user

tries
to insert a sheet, so that any sheet inserted already has the formatting

and
other hidden ranges needed inside it. Part of this process involves
unprotecting the current activesheet, making some changes, then

reprotecting
it.

The activesheet object seems to be accessible programitcally when all

sheets
have been selected - at least in regards to retreiving property values -

but
falls over when the unprotect and protect methods are called.

The user shouldn't really be selecting multiple sheets but they shouldn't

be
seeing such errors either. Is there any way of checking to see if multiple
sheets have been selected from within VBA code within the spreadsheet?
Activesheet doean't seem to provide me with any useful information and I
would prefer to avoid calling any methods to check to see if any errors

are
returned.

I'm currently using Excel 2003, but the solution would have to work in

Excel
97 too.

---
Patrick Seurre



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Selecting all sheets and sheet methods

DaveO plan seems good

Else create a hidden sheet

on Insert sheet event first activate hidden sheet, ensuring only one
sheet is activated

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
selecting a single sheet from a volume of sheets in a workbook No News Excel Worksheet Functions 12 July 1st 06 05:29 AM
Selecting sheets - II Dr.Schwartz Excel Discussion (Misc queries) 4 July 25th 05 02:31 PM
Selecting all sheets Ron de Bruin Excel Programming 1 May 10th 04 07:56 PM
Changing the value in multiple sheets without selecting those sheets herm Excel Programming 3 October 14th 03 03:50 PM
selecting sheets jacqui[_2_] Excel Programming 0 September 11th 03 02:46 PM


All times are GMT +1. The time now is 09:35 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"