Closed Thread
Results 1 to 2 of 2

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. :-)

    ----
    With Me
    If Worksheets("Pivot_Planogramm").Range("BE6").Formula >= .Range("D31") And Worksheets("Pivot_Planogramm").Range("BE6") <= .Range("E31") And Worksheets("Code").Range("C4") = 1 Then
    .Shapes("Form 1a").Fill.ForeColor.RGB = Range("F31").Interior.Color

    ElseIf Worksheets("Pivot_Planogramm").Range("BE6") >= .Range("D32") And Worksheets("Pivot_Planogramm").Range("BE6") <= .Range("E32") And Worksheets("Code").Range("C4") = 1 Then
    .Shapes("Form 1a").Fill.ForeColor.RGB = Range("F32").Interior.Color

    ElseIf Worksheets("Pivot_Planogramm").Range("BE6") >= .Range("D33") And Worksheets("Pivot_Planogramm").Range("BE6") <= .Range("E33") And Worksheets("Code").Range("C4") = 1 Then
    .Shapes("Form 1a").Fill.ForeColor.RGB = Range("F33").Interior.Color

    ElseIf Worksheets("Pivot_Planogramm").Range("BE6") >= .Range("D34") And Worksheets("Pivot_Planogramm").Range("BE6") <= .Range("E34") And Worksheets("Code").Range("C4") = 1 Then
    .Shapes("Form 1a").Fill.ForeColor.RGB = Range("F34").Interior.Color

    ElseIf Worksheets("Pivot_Planogramm").Range("BE6") >= .Range("D35") And Worksheets("Pivot_Planogramm").Range("BE6") <= .Range("E35") And Worksheets("Code").Range("C4") = 1 Then
    .Shapes("Form 1a").Fill.ForeColor.RGB = Range("F35").Interior.Color

    Else
    .Shapes("Form 1a").Fill.ForeColor.RGB = vbWhite
    End With
    End If

  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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,418

    Re: VBA Loops

    Do not open duplicate and triplicate threads!

    Go here, please: http://www.excelforum.com/excel-prog...vba-loops.html

    You also need to fulfil the request for code tags in that thread.

    Thread closed.
    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.

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Using For or Do Until loops
    By alb2p in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-14-2013, 04:52 PM
  2. VBA loops
    By Malowle in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 09-13-2012, 05:30 PM
  3. VBA Loops
    By jeskit in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-24-2011, 10:26 AM
  4. for loops
    By jenkins in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-06-2010, 05:21 AM
  5. Help with Loops
    By manojparmar in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-21-2006, 05:28 AM
  6. Loops...
    By Willabo in forum Excel General
    Replies: 2
    Last Post: 06-14-2006, 11:15 AM
  7. [SOLVED] do loops
    By saravanan in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-13-2006, 05:55 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