Results 1 to 2 of 2

Calling loops in the correct order, I seem to be overwriting but can't see the point where

Threaded View

  1. #1
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Calling loops in the correct order, I seem to be overwriting but can't see the point where

    I was playing around with a comment adding macro requested by another member

    https://www.excelforum.com/excel-pro...t=#post4981390

    I I decided as an exercise to try to shorten the code by working out the permutations (First attempt)

    I think I have the correct controls in place for the macro to pull the data from columns 5 and 7 into the comment for the correct date but when I extend passed the first 2 rows I seem to tripping over because I must be calling in the wrong order. The furthest I've got is populating the first 4 rows with the correct data.
    Would someone with more knowledge of these loops please point me in the right direction.
    Sub Add Comment_Click()
    
    Dim i, ii, iii, iiii As Integer
    Dim ws As Worksheet
    Dim myArr1 As Variant
    
    'i = month days (1 to 31)
    'ii = month comment 1 and comment 2 rows (4 to 28)
    'iii = month days to start next month off on right row sheet 2(myArr1)
    'iiii = control figure for (2*ii)-iiii to keep column number at 5 and seven - see columns sheet1(4 to 51)
    myArr1 = Array(1) 'complete myArr1 = Array(1, 32, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334)
    Set ws = Worksheets("Calendar Overview")
    
    With ws
    
        For Each iii In myArr1
    
                
                    
                    For ii = 4 To 5 ' complete range 4 to 27
                        For iiii = 3 To 3 'complete range 3 to 47
                            For i = 1 To 31
                                On Error Resume Next
                                If Cells(ii, i + 2).Interior.ColorIndex = 16 Then GoTo 0
                                Cells(ii, i + 2).Comment.Delete
                                Cells(ii, i + 2).AddComment
                                Cells(ii, i + 2).Comment.Text Text:=Sheets("Admin 2019 Calendar").Cells(i + iii, ((2 * ii) - iiii)).Text
                                Cells(ii, i + 2).Comment.Shape.TextFrame.AutoSize = True
                                Cells(ii, i + 2).Comment.Shape.TextFrame.Characters.Font.Size = 12
    0:
                            Next i
                         Next iiii
                        Next ii
                    Next
    
       
    End With
    End Sub
    I should have spent my time working out how to fill them from probably a faster array method but this thing just got stuck in my head...
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA Loops - Assign a BAD rating based on recurring instances without overwriting
    By olechkq in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-16-2018, 02:27 PM
  2. [SOLVED] Formula for Predictions League - 3 points correct score or 1 point correct result
    By daveyboy1681 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 08-17-2016, 04:09 PM
  3. [SOLVED] No calling correct script
    By floydian in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-15-2013, 05:14 AM
  4. [SOLVED] loops not incrementing to display correct cell value
    By jmethejedi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-03-2012, 12:55 AM
  5. How to Chart the Maximum Point within Two Loops
    By Faye in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 05-11-2006, 03:00 PM
  6. [SOLVED] Correct Syntax for Calling other Subs
    By Andibevan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2005, 10:05 AM
  7. [SOLVED] SpinButton control loops infinitly when calling a ATL COM server
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-16-2005, 02:06 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