+ Reply to Thread
Results 1 to 4 of 4

Making proper names out of concatenated string variables

  1. #1
    Registered User
    Join Date
    07-21-2010
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    44

    Making proper names out of concatenated string variables

    I am trying to create proper names on the fly by concatenating variables that form a string name that can used as a substitute for predefined names as in the name of a subroutine. I want to try and get a subroutine called based on where the active cell is located by row and column number variables. The basic code is as follows:

    Please Login or Register  to view this content.
    I get a "Compile error" message, with explanation "Expected Sub, Function or Property" on the line "Call strSub"

    Is there a work around?

    Danny
    Last edited by TryToExcel; 07-23-2010 at 03:47 PM. Reason: No code tags and better clarification of intent of code

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Making proper names out of concantenated string variables

    Hi TryToExcel
    possibly
    Please Login or Register  to view this content.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Making proper names out of concantenated string variables

    Generally speaking you can use

    Please Login or Register  to view this content.
    However, for whatever reason it won't work where the Sub Routine name is an alpha numeric string like Sub44 .. if you prefix the number with say _ it will work, eg Sub_44

    Please Login or Register  to view this content.
    and Sub routine is named Sub_44

    However, I suspect you don't really need all the different sub routines - ie the above is an unusual approach.

  4. #4
    Registered User
    Join Date
    07-21-2010
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    44

    Re: Making proper names out of concantenated string variables

    Thanks for the help, that did the trick. I tried the same technique with a "GoTo" statement for a label but it won't work. I wouldn't have to call subroutines if all my code was in the code.

    Please Login or Register  to view this content.
    Danny

+ 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