+ Reply to Thread
Results 1 to 2 of 2

Can't pass a variable value from a worksheet sub to a userform sub

  1. #1
    Registered User
    Join Date
    04-20-2012
    Location
    Oneida, NY
    MS-Off Ver
    Excel 2010
    Posts
    42

    Can't pass a variable value from a worksheet sub to a userform sub

    I am trying to pass two variables RARD and CARD from Sheet1 'change selection' subroutine to the 'Set ARD Command button click' subroutine. The variable value remain empty and it gives me a 1004 error when I try to execute this line of code:

    Please Login or Register  to view this content.
    What I am trying to do is put the text value 'ARD' in the cell on sheet1 which was the original cell I clicked on to open the userform2. To do this I click on the 'Set ARD' button on the userform2 which is then suppose to hide the userform2 and put the 'ARD' text in the selected cell on Sheet1.

    I have attached the workbook for your review.

    Thanks for your help

    Dan

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Can't pass a variable value from a worksheet sub to a userform sub

    Hi Dan,

    You can't declare a 'Public' item in a Sheet.

    Move the following into an ordinary module (e.g. 'Module1'):
    Please Login or Register  to view this content.
    As an additional suggestion, to prevent typos from ruining days and weeks of work you need 'Option Explicit' at the top of each code module.
    This forces you to declare every variable.
    http://www.cpearson.com/excel/DeclaringVariables.aspx

    Lewis

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Pass Value of combobox selected in Userform as input to textbox of other userform
    By Pradeepg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-29-2013, 10:32 AM
  2. Get UserForm checkbox caption and pass to another UserForm on click or mouse down
    By tulsaguy71 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-08-2013, 11:07 AM
  3. Pass Variable From UserForm to Module
    By BLLMRC in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-24-2013, 12:41 PM
  4. [SOLVED] Pass variable from module to userform and back
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-20-2006, 11:50 AM
  5. [SOLVED] Pass public variable from one userform to a second...
    By Mike Dunworth in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-03-2005, 08:05 PM

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