+ Reply to Thread
Results 1 to 4 of 4

Userform takes variable data

Hybrid View

vin1 Userform takes variable data 06-08-2011, 06:08 AM
snb Re: Userform takes variable... 06-08-2011, 06:25 AM
vin1 Re: Userform takes variable... 06-08-2011, 07:11 AM
royUK Re: Userform takes variable... 06-08-2011, 08:02 AM
  1. #1
    Forum Contributor
    Join Date
    02-07-2011
    Location
    netherlands
    MS-Off Ver
    Excel 2003
    Posts
    128

    Userform takes variable data

    Hi i got some problem with my userform.

    In my project i have to run a userform 2 times to do the same actions for a diffrent sheet.
    The userform takes its sheet from a number (1 or 2)
    However i am not sure how to let the userform know which number he should get at initialization.

    To keep it simple i want for the first time the userform runs i need an integer number 1 and the second time it runs i need an integer number 2.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Userform takes variable data

    In that case you can load the userform and use it's tag property in the activate event to indicate that it's using integer 1,
    you can 'close' the userform using 'hide'. The next time you open the userform you can test it's tag property.

    Sub snb()
       userform_snb.show
    
       userform_snb.show         '    open the userform for the second time
    End sub
    
    Private Sub userform_activate()
      tag=val(tag)+1
      Textbox1.Text=sheets(val(tag)).range("A1")
    End Sub
    
    Private Sub knop_sluit_Click()
      Hide
    End Sub



  3. #3
    Forum Contributor
    Join Date
    02-07-2011
    Location
    netherlands
    MS-Off Ver
    Excel 2003
    Posts
    128

    Re: Userform takes variable data

    Do you mean activate event by the init event?

    Also re-using the same userform is not the best way. it means i have to empty all variables and run the userform again. but then with a diffrent integer stored.
    so its easyer to empty all variables and simply get 1 integer from a diffrent module into reloaded userform.
    But im not sure wether thats possible.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Userform takes variable data

    Use a CheckBox to determine which to use
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ 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