+ Reply to Thread
Results 1 to 4 of 4

AddIn to delete sheet

  1. #1
    Soniya
    Guest

    AddIn to delete sheet

    Is it possible to restrict use of an addin to certain sheets?

    for eg If the active workbook contains sheet ABC or DEF then delete the
    sheet else run the function.

    Thanks


  2. #2
    Robert Mulroney
    Guest

    RE: AddIn to delete sheet


    This seems a reasonibly strange (if not dangerous) thing to want to do but:

    Public Sub removeSheets()
    Dim ws As Worksheet
    For Each ws In ActiveWorkbook.Worksheets
    Debug.Print ws.Name
    If ws.Name <> "Sheet1" Then
    Application.DisplayAlerts = False
    Worksheets(ws.Name).Delete
    Application.DisplayAlerts = True
    End If
    Next
    End Sub


    You might consider opening the workbooks as read-only so you don't
    accidentally lose data.


    - Rm


    "Soniya" wrote:

    > Is it possible to restrict use of an addin to certain sheets?
    >
    > for eg If the active workbook contains sheet ABC or DEF then delete the
    > sheet else run the function.
    >
    > Thanks
    >
    >


  3. #3
    Soniya
    Guest

    Re: AddIn to delete sheet

    I think this wont work...

    what i am looking for is to restrict the use of a function which is
    available through a running Add In which is availbale globally.

    the function gives a calculated result. I just want this function not
    to work in certain sheets. for eg. if the sheet name is "abc" then
    instead of the calculated result an "error" result will also do. in any
    other case it shud give the result.

    thanks


  4. #4
    Robert Mulroney
    Guest

    Re: AddIn to delete sheet



    sorry I think I misunderstood....

    >for eg If the active workbook contains sheet ABC or DEF then delete the
    >sheet else run the function.


    The code I posted will delete sheets in a workbook depending on their name.

    > the function gives a calculated result. I just want this function not
    > to work in certain sheets......


    In this situation you could potentially use Activesheet.Name to get the name
    of the sheet that is being used:

    if activesheet.name <> "ABC" then
    'Return a value
    else
    'Return error
    end if

    This isn't a perfect solution because there is the potential to use this
    call calculate on sheet ABC with another sheet selected.

    sheets("ABC").calculate

    That could potentially return an undesirable result.

    That's the best that I can think of. If it's really essential that the
    function is not run on the wrong sheet. Say if you want to protect
    confidental information, I suggest that you think about redesigning your
    system and using the protection of private functions. I know this is what
    you're trying to avoid.

    The problem with using the sheet name to protect a function is that there is
    nothing to stop a user renaming a sheet.


    - Rm


    "Soniya" wrote:

    > I think this wont work...
    >
    > what i am looking for is to restrict the use of a function which is
    > available through a running Add In which is availbale globally.
    >
    > the function gives a calculated result. I just want this function not
    > to work in certain sheets. for eg. if the sheet name is "abc" then
    > instead of the calculated result an "error" result will also do. in any
    > other case it shud give the result.
    >
    > thanks
    >
    >


+ 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