+ Reply to Thread
Results 1 to 3 of 3

Create a loop by defining X as integer, to shorten length of code

  1. #1
    Registered User
    Join Date
    03-11-2013
    Location
    Perrysburg, Ohio, USA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Question Create a loop by defining X as integer, to shorten length of code

    Hi guys,

    I have some code which I know can be shortened by using a loop such as "Dim X as Integer" "from 1 to 50" "Next x", or something like that.

    However, I have tried many variations of the code, and since I am a novice, I cannot get it to work!

    This is a UserForm where I want to change the color of 'labels' based on whether the value in the spreadsheet in 1 or 0. Here is the code:

    Please Login or Register  to view this content.
    My labels go from 1 to 50, as do the corresponding cells T1 to T50. Instead of copying and pasting this code fifty times, how I do I create a loop?

    Any help would be greatly appreciated! Thanks.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Create a loop by defining X as integer, to shorten length of code

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    03-11-2013
    Location
    Perrysburg, Ohio, USA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Create a loop by defining X as integer, to shorten length of code

    Thanks, this is working great!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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