+ Reply to Thread
Results 1 to 15 of 15

Problem deleting worksheet name as variable from a list

  1. #1
    Registered User
    Join Date
    05-24-2013
    Location
    Bournemouth, England
    MS-Off Ver
    Excel 2007
    Posts
    8

    Problem deleting worksheet name as variable from a list

    Hello all,

    I hope you can assist.

    I am trying to capture the current worksheet name, switch to another worksheet then delete that name from a list in a range. The routine appears to complain at the "find" part, not liking envtodelete as a variable.

    Any assistance warmly recieved, thankyou

    Paul

    ***

    Sub RemoveEnvFromTimecalc()

    ActiveSheet.Name = thissheet

    Dim envtodelete As New DataObject
    envtodelete.SetText thissheet
    envtodelete.PutInClipboard
    Sheets("TimeCalc").Select

    Range("B29:R29").Select
    Selection.Find(What:=envtodelete, After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False).Activate
    Selection.ClearContents

    End Sub
    Last edited by zondervanamo; 06-06-2013 at 12:34 PM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Problem deleting worksheet name as variable from a list

    Paul

    Why are you using the clipboard and why are you setting the activesheet's name to thissheet?

    If you want to put the name of the active sheet in thissheet this is the code.
    Please Login or Register  to view this content.
    Now instead of using the clipboard replace envtodelete with thissheet in the Find.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    05-24-2013
    Location
    Bournemouth, England
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Problem deleting worksheet name as variable from a list

    Thanks Norie,

    Thanks for your code approach, when I run this though I get the same

    Run time error '13':

    Type mismatch


    on the Set rngFnd statement as I was getting with the previous method.

    Paul
    Last edited by zondervanamo; 06-06-2013 at 12:33 PM.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Problem deleting worksheet name as variable from a list

    Does this work?
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-24-2013
    Location
    Bournemouth, England
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Problem deleting worksheet name as variable from a list

    Thank you Norie,

    This doesn't seem to be doing it - I'm wondering if the issue is that the "thissheet" is actually a current multipage tab on a form rather than an active worksheet. Would you know the syntax if the ought to be different?

    Best regards,

    Paul

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Problem deleting worksheet name as variable from a list

    Paul

    That's completely different.

    A tab on a multipage control isn't a sheet, it's a page.

    Where is your list located?

  7. #7
    Registered User
    Join Date
    05-24-2013
    Location
    Bournemouth, England
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Problem deleting worksheet name as variable from a list

    The list is on a worksheet (definitely a sheet) called "TimeCalc" and is in the range of B29:R29

    The items in the list each refer to a created worksheet, which also has a corresponding page (multitab control)

    Essentially, we have two button on the multitabbed form - a create button that does the following:

    1. Adds a new multitab page (which is a form for user input)
    2. Adds a corresponding worksheet which holds the data entered.
    3. Adds the worksheet name to the range on TimeCalc

    What I'm trying to do with this routing is:

    1. Delete the worksheet
    2. Delete the current multitab page
    3. Remove the current multitab page name from the list in TimeCalc

    Eg the creation process in reverse. Steps 1 and 2 work ok, but step three does not, and this is my current problem.

    Thanks for your time on this, really appreciated.

    Paul

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Problem deleting worksheet name as variable from a list

    Paul

    Why are you adding/deleting pages/worksheets?

    Can you upload an example workbook?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  9. #9
    Registered User
    Join Date
    05-24-2013
    Location
    Bournemouth, England
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Problem deleting worksheet name as variable from a list

    Hi,

    It's basically project time estimator, so each page we add is a new project.

    Each project has a multipage control, a new sheet in the workbook, and an entry on the list. We can add them but not delete fully.

    I'm afraid I can't load an example of the whole workbook up as it contains sensitive data, but have loaded up some screens which should hopefully illustrate what we're trying to do.

    thanks,

    Paul
    Attached Files Attached Files

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Problem deleting worksheet name as variable from a list

    Paul

    Why a separate page for each project?

    Are the inputs on each project completely different?

  11. #11
    Registered User
    Join Date
    05-24-2013
    Location
    Bournemouth, England
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Problem deleting worksheet name as variable from a list

    We need a separate multipage form for each project to display the data to the user.

    The separate corresponding sheets are to help us manage things at the back end. Each sheet is created from a master sheet which is used as a template to insert the data into the corresponding project sheets. I think we could have used a table, but I still think we'd have been faced with the same issue as the TimeCalc list is integral to how the calculations work at the back end..

    It's clunky, but the number of sheets doesnt really seem to be a problem, its just carrying this present multipage value over as a value to remove from that list when we hit that delete button.

  12. #12
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Problem deleting worksheet name as variable from a list

    Why not just have one page and a combobox?

    Choose a project in the combobox and code populates the page with the data for that project.

  13. #13
    Registered User
    Join Date
    05-24-2013
    Location
    Bournemouth, England
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Problem deleting worksheet name as variable from a list

    We want the final users to be able to populate the data without going near the back end, so this is why we're using forms. We're quite a long way down the build of the whole workbook, and can't really redevelop at this stage, but stuck on this list removal routine syntax.

  14. #14
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Problem deleting worksheet name as variable from a list

    I never mentioned doing anything on a worksheet.

    I mean have one page on a userform and have a combobox which lists the projects on the same userform.

    The user selects a project from the combobox and the data for that project is loaded onto the page in the userfrom.

  15. #15
    Registered User
    Join Date
    05-24-2013
    Location
    Bournemouth, England
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Problem deleting worksheet name as variable from a list

    The relationship of the data to the forms is one to many.

    So a one-type large table (or currently tables on separate worksheets) on the back end that contains all possible fields, but there are several different types of user form that ask different questions of the inputter, which would rule out a single user form.

+ 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