Loop - copy & paste

Vishaal

Well-known Member
Joined
Mar 16, 2019
Messages
543
Office Version
  1. 2010
  2. 2007
Platform
  1. Windows
  2. Web
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)
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
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:
Upvote 0
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:
Upvote 0
For values only use
Code:
Sub Vishaal()
   Range("B12:AY24").Value = Range("A12:A24").Value
End Sub
 
Upvote 0
In this code

Can we paste values instead of formula

It is possible
 
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,128
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top