+ Reply to Thread
Results 1 to 7 of 7

how to pass a label as an argument

  1. #1
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    how to pass a label as an argument

    so i have this code for label 1 that i would like to stream line but getting run time error 13 type mismatch

    Please Login or Register  to view this content.
    and here is the sub:

    Please Login or Register  to view this content.
    when i type in the immediate window the following:

    Please Login or Register  to view this content.
    label question.png

    i get a "Label" which seems right but when i pass that in the labelclick, it returns the caption of the label and not the label number. what am i doing wrong?

    label caption not label number.jpg
    Attached Files Attached Files
    Last edited by dmcgov; 07-23-2020 at 08:13 AM.

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: how to pass a label as an argument

    Try
    Please Login or Register  to view this content.
    and
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: how to pass a label as an argument

    A Copy of the workbook would help.

    Perhaps you need the TabIndex property?
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how to pass a label as an argument

    richard, i just added the file.

    torachan, not sure those will work as the sub's argument is for a label number but i will try.

  5. #5
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how to pass a label as an argument

    torachan, tried but did not work. what i want returned is the label number as that is needed in the sub CallLblClk. how can i make that work?

  6. #6
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how to pass a label as an argument

    so fixed it (yay) by doing the following in the sub header:

    Please Login or Register  to view this content.
    now this works for click event 1:

    Please Login or Register  to view this content.

  7. #7
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: how to pass a label as an argument

    Too late now to solve your problem.
    I knew in the back of my mind I had similar problems passing variables from UserForm to a print routine in a module.
    My trouble is with advancing years I have forgotten more than I have learned and have to trawl through my archives.
    In that particular instance I did not want to declare global variables, so declared the same variable in the UserForm and Module.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

+ 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 Sheet name as argument to function
    By Umair.711 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 11-04-2014, 07:20 AM
  2. VBA Argument pass to DLL Issue
    By DougD720 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-27-2014, 09:11 PM
  3. pass control as argument
    By horbay in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-17-2011, 09:04 AM
  4. Pass argument to SetSourceData
    By khdani in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 10-22-2008, 07:54 AM
  5. [SOLVED] Pass function as argument to UDF
    By Ron Rosenfeld in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-09-2006, 08:55 AM
  6. Pass Argument?
    By Hal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-05-2005, 01:20 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