+ Reply to Thread
Results 1 to 6 of 6

VBA Loops

  1. #1
    Registered User
    Join Date
    12-15-2016
    Location
    Zug
    MS-Off Ver
    2010
    Posts
    5

    VBA Loops

    Hi everyone

    I have been teaching myself VBA and have now started coding bigger "Projects". However, I am pretty unfamiliar with code Loops, which is why my codes are pretty insufficient and Long. :-) I have tried to read and learn how to shorten my specific codes but could unfortunately not find anything. I would therefore be very happy and appreciate it, if someone of the pros could give me a hint on how to shorten the below code.

    Thanks a lot in advance and a great day to the Excel community. :-)

    ----

    Please Login or Register  to view this content.
    Last edited by Robinkio; 12-15-2016 at 08:03 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,339

    Re: VBA Loops

    Code tags now added - thanks!
    Last edited by AliGW; 12-15-2016 at 08:22 AM.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    12-15-2016
    Location
    Zug
    MS-Off Ver
    2010
    Posts
    5

    Re: VBA Loops

    Hello Thanks for your explanation and apologies for not doing it right the first time.

    Brgds

    Robinkio

  4. #4
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: VBA Loops

    Hi,
    To make some loop you need to know that exactly you want to change in each loop step.
    Take a look at your code:
    Please Login or Register  to view this content.
    Looks like green ranges should not change, but red should be changed in each step.
    Cycle then will be:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-15-2016
    Location
    Zug
    MS-Off Ver
    2010
    Posts
    5

    Re: VBA Loops

    Hello Kasan and thanks a lot for your quick reply. This is great and helps a lot already. However, the green marked code will also Change, but like this. Have a look at the following code and how it continues below. I have different forms/shapes in Excel that Change the Color according to their own value. In your solution, I can already shorten it as I apply "For i = 31 to 35" for the red marked codes. Would this also be possible for the green marked codes?

    First form
    Please Login or Register  to view this content.
    Second form
    Please Login or Register  to view this content.
    Third form:
    Please Login or Register  to view this content.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,339

    Re: VBA Loops

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

+ 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. Using loops in VBA
    By reefswaggie in forum Excel - New Users/Basics
    Replies: 7
    Last Post: 05-11-2012, 02:28 PM
  2. VBA Loops
    By randomperson15 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-06-2010, 12:40 AM
  3. for loops
    By jenkins in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-06-2010, 05:21 AM
  4. Loops in VBA
    By kjones505 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-18-2009, 05:43 AM
  5. [SOLVED] do loops
    By saravanan in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-13-2006, 05:55 AM
  6. Loops
    By alecbowman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-11-2006, 04:30 AM
  7. For next loops
    By Kate in forum Excel General
    Replies: 5
    Last Post: 05-22-2006, 08:15 AM

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