+ Reply to Thread
Results 1 to 6 of 6

Passing variables from sub to user form

  1. #1
    Registered User
    Join Date
    08-14-2009
    Location
    Bristol, England
    MS-Off Ver
    Excel 2003
    Posts
    12

    Passing variables from sub to user form

    I can pass a variable from sub to sub no problem and have tried to do it the same way between a sub and user form but i keep getting the error

    Compile Error:
    ByRef argument type mismatch
    This is the code i am using

    Please Login or Register  to view this content.
    Can someone help please

  2. #2
    Forum Contributor
    Join Date
    06-14-2008
    Posts
    153

    Re: Passing variables from sub to user form

    Hi,

    This message means that one or more of the data types defined in your form are not the same as those in the module. If your module is declared like this:
    Please Login or Register  to view this content.
    Then ABC should have the same data type as CLICK and XYZ should have the same data type as ADDRESSES in your CALL statement.
    Welcome to: http://www.exceldigest.com/myblog/
    "Excel help for the rest of us"

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

    Re: Passing variables from sub to user form

    What are you actually trying to do? What aer you expecting UserForm1.Show(click) to do?
    Hope that helps.

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

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    08-14-2009
    Location
    Bristol, England
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Passing variables from sub to user form

    i have a sheet that i need to run a filter on to pull out certain data, is then saved as a temp file and attached to an email, the userform contains a combo box with several cases in, for each case there is a number of email addresses that the attachment is then sent to. Because the new workbook is book1, book2 etc the click is counting how many new sheets are created and using that to get to the relevant window. As the name of the main workbook changes with each week i cannot deirectly reference the sheets as it can get messy. I need to pass the click variable and the addresses from the appropriate case to a sub that then sets up and sends the email. i can attach a copy of the spreadsheet if it would help

  5. #5
    Registered User
    Join Date
    08-14-2009
    Location
    Bristol, England
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Passing variables from sub to user form

    ok my bad sorry, i hadn't declared addresses in the sendmail function

    this is the working code

    Main Page

    Please Login or Register  to view this content.
    User Form

    Please Login or Register  to view this content.
    send mail

    Please Login or Register  to view this content.

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

    Re: Passing variables from sub to user form

    Sounds messy to me, can you attach an example workbook with dummy data in? I can't see why you don't create the temp file, email it then delete it. Certainly you could rename it on creation.

+ 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