Page 1 of 5 123 ... LastLast
Results 1 to 10 of 41

Thread: Loop - copy & paste
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Mar 2019
    Posts
    205
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Default Loop - copy & paste

    Hi,

    Thanks in advance,

    I am copying the formula from Range ("A12:A24")
    And after select the next range ("B12") and paste it
    Again select the next range ("C12") and paste it
    Again select the next range ("D12") and paste it

    How can i do it through loop or vba (Coloumn B to AY)

  2. #2
    Board Regular
    Join Date
    Mar 2015
    Location
    Syria
    Posts
    261
    Post Thanks / Like
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Loop - copy & paste

    Try
    Code:
    Sub copy_formula()
        Set Rng = Range("a12:a24")
        With ActiveSheet
            For i = 1 To 50
                
                Rng.copy Range(Cells(12, i + 1), Cells(24, i + 1))
            Next
        End With
    End Sub
    Last edited by mohadin; Aug 31st, 2019 at 07:26 AM.

  3. #3
    Board Regular
    Join Date
    Mar 2015
    Location
    Syria
    Posts
    261
    Post Thanks / Like
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Loop - copy & paste

    Improved code
    Code:
    Sub copy_formula()
        With ActiveSheet
        Set Rng = Range("a12:a24")
       Rng.copy
            For i = 2 To 50
               .Cells(12, i ).PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
            SkipBlanks:=False, Transpose:=False
            Next
        End With
    End Sub
    Last edited by mohadin; Aug 31st, 2019 at 07:41 AM.

  4. #4
    Board Regular
    Join Date
    Sep 2016
    Posts
    2,582
    Post Thanks / Like
    Mentioned
    36 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Loop - copy & paste

    Code:
    [A12:A24].Copy [B12:AY24]

  5. #5
    Board Regular
    Join Date
    Mar 2015
    Location
    Syria
    Posts
    261
    Post Thanks / Like
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Loop - copy & paste

    You are great
    Quote Originally Posted by footoo View Post
    Code:
    [A12:A24].Copy [B12:AY24]

  6. #6
    Board Regular
    Join Date
    Mar 2019
    Posts
    205
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Loop - copy & paste

    Thanks Mohadin Sir Ji

    Its working

  7. #7
    Board Regular
    Join Date
    Mar 2019
    Posts
    205
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Loop - copy & paste

    In this code how can we paste values

  8. #8
    Board Regular
    Join Date
    Mar 2015
    Location
    Syria
    Posts
    261
    Post Thanks / Like
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Loop - copy & paste

    You are well come
    Glad You like it
    Quote Originally Posted by Vishaal View Post
    Thanks Mohadin Sir Ji

    Its working

  9. #9
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    28,298
    Post Thanks / Like
    Mentioned
    471 Post(s)
    Tagged
    47 Thread(s)

    Default Re: Loop - copy & paste

    For values only use
    Code:
    Sub Vishaal()
       Range("B12:AY24").Value = Range("A12:A24").Value
    End Sub
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  10. #10
    Board Regular
    Join Date
    Mar 2019
    Posts
    205
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Loop - copy & paste

    In this code

    Can we paste values instead of formula

    It is possible

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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