+ Reply to Thread
Results 1 to 2 of 2

Calling different subroutines from a for/next loop based on a counter

  1. #1
    Registered User
    Join Date
    02-11-2016
    Location
    Nashville, TN
    MS-Off Ver
    2010
    Posts
    1

    Calling different subroutines from a for/next loop based on a counter

    Hello everyone,

    I'm using VBA in a rather unconventional way by moving some hexagons around on the worksheet. And I want the hexagons to be arranged in a certain way. I did the tedious task of recording all of the different macros necessary to move the hexagons into their specific positions. So I now have 15 independent subroutines that each specify where a different hexagon is meant to go.

    The following code is the general idea of what I want to accomplish. Is this possible?
    Note: let's pretend all moving macros are named Move1, Move2, Move3....Move15

    dim counter as integer
    dim hex_macro as string
    for counter = 1 to counter = 15
    hex_macro = "Move" & counter
    Call hex_macro
    next counter

    Thank you for your input!!!

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Calling different subroutines from a for/next loop based on a counter

    Try something like this...

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

+ 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] Error when calling two similar subroutines at the same time
    By rawcode in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-10-2013, 07:24 AM
  2. Calling Subroutines in Other Modules
    By Vladamir in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-31-2012, 04:09 AM
  3. Calling a subroutines with a variable argument at a specific time
    By sumanc_nitr in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-20-2010, 04:02 PM
  4. Calling subroutines
    By kevlaw in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-02-2008, 08:13 AM
  5. Calling SubRoutines
    By diannk in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-18-2008, 03:51 PM
  6. Calling subroutines and passing variables
    By matpj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-29-2006, 11:25 AM
  7. Calling subroutines and passing variables
    By matpj in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-29-2006, 10:55 AM
  8. Calling subroutines from Class Modules
    By davidm in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-22-2006, 11:42 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