• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

filling array with non-contiguous range

marreco

Member
Hi.

Is possible fill non continguos cells or range?
I want know is possible fill this text ("Cod", "Descr", "DtVenc", "Qtd") in cells
Code:
Sub FillRangeArray()
    With Range("A1,C1, F1, L1") 'How do something like this line?
        .Value = Array("Cod", "Descr", "DtVenc", "Qtd")
        .Font.Bold = True
        .Font.ColorIndex = 2
        .Interior.ColorIndex = 1
    End With
    Columns.AutoFit
End Sub

Thank you!
 
Something like this?
Code:
Sub FillRangeArray()
    Dim x As Variant
    Dim i As Integer: i = 0
    Dim cel As Range
   
    x = Array("Cod", "Descr", "DtVenc", "Qtd")
    With Union(Range("A1"), Range("C1"), Range("F1"), Range("L1")) 'How do something like this line?
        For Each cel In .Cells
            cel.Value = x(i)
            i = i + 1
        Next
        .Font.Bold = True
        .Font.ColorIndex = 2
        .Interior.ColorIndex = 1
    End With
    Columns.AutoFit
End Sub
 
Back
Top