Loop in the same line

%3CLINGO-SUB%20id%3D%22lingo-sub-1716093%22%20slang%3D%22en-US%22%3ELoop%20in%20the%20same%20line%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1716093%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20all%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFrom%20B2%20column%20to%20AF2%20column%2C%20I%20need%20to%20display%20all%20days%20of%20a%20specific%20month.%3C%2FP%3E%3CP%3EThe%20starting%20and%20last%20day%20for%20every%20month%2C%20are%20displayed%20in%20another%20Sheet.%20On%20the%20actual%20Sheet%20who%20I%20need%20to%20display%20something%20like%20a%20Calendar%20in%20VBA%2C%20I%20can%20only%20display%20the%20starting%20date%2C%20but%20I%20don't%20know%20how%20to%20loop%20to%20other%20columns.%20There%20is%20what%20I%20tried%20to%20do%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3EFunction%20FicheAbsence(NomFeuille%20As%20String)%0A%20%20%20%20%0A%20%20%20%20Dim%20Var%20As%20Variant%0A%20%20%20%20Dim%20FL1%20As%20Worksheet%0A%20%20%20%20Dim%20c%20As%20Integer%0A%20%20%20%20Range(%22B1%22).Value%20%3D%20NomFeuille%0A%20%20%20%20%0A%20%20%20%20For%20i%20%3D%201%20To%2012%0A%20%20%20%20%20%20%20%20If%20NomFeuille%20%3D%20Application.Sheets(%22DB%22).Range(%22A%22%20%26amp%3B%20i%20%2B%203).Value%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20Range(%22B2%22).Value%20%3D%20Application.Sheets(%22DB%22).Range(%22B%22%20%26amp%3B%20i%20%2B%203).Value%0A%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20Next%20i%0A%20%20%20%20%0AEnd%20Function%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EHow%20can%20I%20loop%20in%20different%20columns%20but%20in%20the%20same%20line.%20The%20first%20day%20is%20displayed%20in%20B2.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1716093%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
Occasional Contributor

Hi all,

 

From B2 column to AF2 column, I need to display all days of a specific month.

The starting and last day for every month, are displayed in another Sheet. On the actual Sheet who I need to display something like a Calendar in VBA, I can only display the starting date, but I don't know how to loop to other columns. There is what I tried to do:

Function FicheAbsence(NomFeuille As String)
    
    Dim Var As Variant
    Dim FL1 As Worksheet
    Dim c As Integer
    Range("B1").Value = NomFeuille
    
    For i = 1 To 12
        If NomFeuille = Application.Sheets("DB").Range("A" & i + 3).Value Then
            Range("B2").Value = Application.Sheets("DB").Range("B" & i + 3).Value
            
        End If
    Next i
    
End Function

How can I loop in different columns but in the same line. The first day is displayed in B2.

 

0 Replies