+ Reply to Thread
Results 1 to 4 of 4

Tricky. Upon deactivating a ws, trying to launch a form.. can't pass ws name into form

  1. #1
    Registered User
    Join Date
    10-28-2012
    Location
    Notre Dame, IN
    MS-Off Ver
    Excel 2010
    Posts
    4

    Question Tricky. Upon deactivating a ws, trying to launch a form.. can't pass ws name into form

    Trying to create a TaskManager: create some tasks, each of which has its own worksheet. Each worksheet has a series of steps, with a Y/N drop down to check if each step is complete.

    When the user leaves the page, (deactivate sheet), I want to launch a form which is populated with each of the steps with a N completion status, or if all the steps are complete, archive and delete the task.
    That's all done.

    The problem is that upon deactivating a sheet, the next sheet becomes the ActiveSheet, so I can't use that in my code (I want to check the values in the deactivating sheet). I've resolved that by dimming shP (sheetPrevious) as the sheet that is being deactivated, but I can't seem to pass that sheet into the form, so the form keeps collecting from the new sheet.

    Here's the code for the Deactivate, which only has an error upon calling the form. (shP is a global variable, Dim on Workbook page public)


    Please Login or Register  to view this content.
    And here is the Form Initialize Code, which populates the form (I tried making it public too, that hasn't changed anything), ws is a public variable as well

    Please Login or Register  to view this content.
    Any idea how to pass in the value for shP into the form????
    Last edited by Leith Ross; 12-04-2012 at 12:49 AM. Reason: Added Code tags

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Tricky. Upon deactivating a ws, trying to launch a form.. can't pass ws name into form

    Hello crobins8,

    Welcome to the Forum!

    The only way to pass the sheet name to the UserForm is by using the UserForm's Tag property. This property is a string variable. The UserForm must first be loaded into memory before you can assign a value to the Tag. I have made the changes to your code. If you have any problems, lety me know.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    10-28-2012
    Location
    Notre Dame, IN
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Tricky. Upon deactivating a ws, trying to launch a form.. can't pass ws name into form

    Thank you for your help!
    I'm recieving an error here : Compile error, method or data member not found

    TaskCheckupForm.Load

    What would you reccomend?

  4. #4
    Registered User
    Join Date
    10-28-2012
    Location
    Notre Dame, IN
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Tricky. Upon deactivating a ws, trying to launch a form.. can't pass ws name into form

    resolved it. Just had to pull in more of the name

    Public Sub UserForm_Initialize()
    'Often people complete a task, but forget to mark it off as completed. This prompts them with incomplete tasks and asks which they have completed!

    Dim i As Integer
    Dim strStep As String




    lblTitle.Caption = "For the task " & ThisWorkbook.shP.Name & ", did you complete any of these steps?"

    For i = 5 To 50 'collecting all incomplete tasks
    If ThisWorkbook.shP.Range("A" & i) = "N" Then
    strStep = ThisWorkbook.shP.Range("B" & i)
    TaskCheckupForm.lbxTasks.AddItem strStep
    TaskCheckupForm.Height = Height + 10
    'making the form size accomodate the number of entries.
    End If
    Next i


    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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