Consulting

Results 1 to 4 of 4

Thread: copy not contiguous cells via VBA

  1. #1
    VBAX Tutor
    Joined
    Jan 2011
    Posts
    272
    Location

    copy not contiguous cells via VBA

    Hi.
    It would be possible to copy, not contiguous cells via VBA?

    I try, but doesn't work
    Sub Copynon()Dim LR  As Long
    LR = Range("A" & Rows.Count).End(xlUp).Row
    Worksheets("PLANILHA PEDIDO").Range("N10,B10,S10,B22,C22,D22,J22,L22,M22").Copy 'Destination:=Sheets("CONSOLIDAR").Range("A2:I" & LR + 1)
    End Sub
    thanks

  2. #2
    VBAX Newbie
    Joined
    Mar 2014
    Posts
    3
    Location
    hi marreco.

    try the following code to copy the non contiguous cells as contiguous.

    Sub Copynon()
        Dim r_from As Range, r_to As Range
    
        Set r_to = Worksheets("CONSOLIDAR").Range("A" & Rows.Count).End(xlUp).Offset(1)
            For Each r_from In Worksheets("PLANILHA PEDIDO").Range("N10,B10,S10,B22,C22,D22,J22,L22,M22").Areas
            r_from.Copy Destination:=r_to
            Set r_to = r_to.Offset(, 1)
        Next r_from
    End Sub

  3. #3
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    Sub M_snb()
       with sheets(["PLANILHA PEDIDO")
          sheets("CONSOLIDAR").Cells(Rows.Count, 1).End(xlUp).Offset(1).Resize(, 9) = Array(.Range("N10").value, .Range("B10").value, .Range("S10").value, .Range("B22").value, .Range("C22").value, .Range("D22").value, .Range("J22").value, .Range("L22").value, .Range("M22").value)
       end with
    End Sub

  4. #4
    VBAX Tutor
    Joined
    Jan 2011
    Posts
    272
    Location
    Hi. thank you very much!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •