+ Reply to Thread
Results 1 to 10 of 10

How to Know Selected Sheets

  1. #1
    Registered User
    Join Date
    02-07-2006
    Posts
    26

    How to Know Selected Sheets

    I'm making a form to protect all sheets or all selected sheets with a password but trying this I found a problem.
    How can I know all selected sheets at moment of begin the action to apply code only to them ?

    Thanks and Regards
    Daniel.

  2. #2
    Dave Peterson
    Guest

    Re: How to Know Selected Sheets

    dim wks as worksheet

    for each wks in activewindow.selectedsheets
    'your code
    next wks



    dbarelli wrote:
    >
    > I'm making a form to protect all sheets or all selected sheets with a
    > password but trying this I found a problem.
    > How can I know all selected sheets at moment of begin the action to
    > apply code only to them ?
    >
    > Thanks and Regards
    > Daniel.
    >
    > --
    > dbarelli
    > ------------------------------------------------------------------------
    > dbarelli's Profile: http://www.excelforum.com/member.php...o&userid=31275
    > View this thread: http://www.excelforum.com/showthread...hreadid=570888


    --

    Dave Peterson

  3. #3
    Jim Thomlinson
    Guest

    RE: How to Know Selected Sheets

    Give this a try...

    Sub SelectedSheets()
    Dim wks As Worksheet

    For Each wks In ActiveWindow.SelectedSheets
    MsgBox wks.Name
    Next wks
    End Sub

    --
    HTH...

    Jim Thomlinson


    "dbarelli" wrote:

    >
    > I'm making a form to protect all sheets or all selected sheets with a
    > password but trying this I found a problem.
    > How can I know all selected sheets at moment of begin the action to
    > apply code only to them ?
    >
    > Thanks and Regards
    > Daniel.
    >
    >
    > --
    > dbarelli
    > ------------------------------------------------------------------------
    > dbarelli's Profile: http://www.excelforum.com/member.php...o&userid=31275
    > View this thread: http://www.excelforum.com/showthread...hreadid=570888
    >
    >


  4. #4
    Jim Thomlinson
    Guest

    RE: How to Know Selected Sheets

    Sorry... Don't use that procedure name as it is a reserved word (One of the
    properties of the Activewindow as we can see from the code). Change it to
    something else like...

    Sub MySelectedSheets()
    Dim wks As Worksheet

    For Each wks In ActiveWindow.SelectedSheets
    MsgBox wks.Name
    Next wks
    End Sub

    --
    HTH...

    Jim Thomlinson


    "Jim Thomlinson" wrote:

    > Give this a try...
    >
    > Sub SelectedSheets()
    > Dim wks As Worksheet
    >
    > For Each wks In ActiveWindow.SelectedSheets
    > MsgBox wks.Name
    > Next wks
    > End Sub
    >
    > --
    > HTH...
    >
    > Jim Thomlinson
    >
    >
    > "dbarelli" wrote:
    >
    > >
    > > I'm making a form to protect all sheets or all selected sheets with a
    > > password but trying this I found a problem.
    > > How can I know all selected sheets at moment of begin the action to
    > > apply code only to them ?
    > >
    > > Thanks and Regards
    > > Daniel.
    > >
    > >
    > > --
    > > dbarelli
    > > ------------------------------------------------------------------------
    > > dbarelli's Profile: http://www.excelforum.com/member.php...o&userid=31275
    > > View this thread: http://www.excelforum.com/showthread...hreadid=570888
    > >
    > >


  5. #5
    Registered User
    Join Date
    02-07-2006
    Posts
    26
    It was more easy than I think.
    Thanks a lot !!

    Dany.

  6. #6
    Forum Contributor
    Join Date
    10-03-2004
    Posts
    102

    Question Related Query

    I want to create a new workbook and insert two selected sheets. Any ideas?
    Chuckles123

  7. #7
    Dave Peterson
    Guest

    Re: How to Know Selected Sheets

    without too much info to go on...

    Option Explicit
    Sub testme()

    Dim wkbk As Workbook
    Dim newwkbk As Workbook

    Set wkbk = Workbooks("book1.xls")

    Set newwkbk = Workbooks.Add

    wkbk.Worksheets(Array("sheet1", "sheet3")).Copy _
    before:=newwkbk.Worksheets(1)

    End Sub



    Chuckles123 wrote:
    >
    > I want to create a new workbook and insert two selected sheets. Any
    > ideas?
    > Chuckles123
    >
    > --
    > Chuckles123
    > ------------------------------------------------------------------------
    > Chuckles123's Profile: http://www.excelforum.com/member.php...o&userid=14948
    > View this thread: http://www.excelforum.com/showthread...hreadid=570888


    --

    Dave Peterson

  8. #8
    Forum Contributor
    Join Date
    10-03-2004
    Posts
    102

    Thanks, Dave -- I Think This Works

    Thanks very much, Dave.
    I have some add'l code re: this query that I would like to run by you -- I will respond to the thread that I originated last nite.

    Chuckles123

  9. #9
    Tom Ogilvy
    Guest

    Re: How to Know Selected Sheets

    If you mean create a workbook with two selected sheets, just

    wkbk.Worksheets(Array("sheet1", "sheet3")).Copy

    --
    Regards,
    Tom Ogilvy


    "Chuckles123" <Chuckles123.2cfise_1155389706.2603@excelforum-nospam.com>
    wrote in message
    news:Chuckles123.2cfise_1155389706.2603@excelforum-nospam.com...
    >
    > Thanks very much, Dave.
    > I have some add'l code re: this query that I would like to run by you
    > -- I will respond to the thread that I originated last nite.
    >
    > Chuckles123
    >
    >
    > --
    > Chuckles123
    > ------------------------------------------------------------------------
    > Chuckles123's Profile:
    > http://www.excelforum.com/member.php...o&userid=14948
    > View this thread: http://www.excelforum.com/showthread...hreadid=570888
    >




  10. #10
    Forum Contributor
    Join Date
    10-03-2004
    Posts
    102

    Thanks Tom, Very Efficient

    Thanks for your post, Tom.
    Chuckles123

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1