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)
 
Code:
Sub copy_formula()Application.ScreenUpdating = False
    With ActiveSheet
    Set Rng = Range("a12:a24")
   Rng.copy
        For i = 2 To 50
           .Cells(12, i).PasteSpecial Paste:=xlPasteFormulas
        Next
 With Range("b12:ay24")
    .Value = .Value
    End With
    End With
   Application.ScreenUpdating = True
End Sub



Ok checking

Pls give me time

Thanks bro
 
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
But problem is its providing the value of A12:A24 in all
Instead of different values for B12, C12,D12
In that case what values do you want in those cells?
You said you wanted A12:A24 pasted in col B onwards.
 
Upvote 0
In that case what values do you want in those cells?
You said you wanted A12:A24 pasted in col B onward.
Hi Mr.Fluff
As I understand he whats to copy formulas A12:A24 to col B onward then get the values of the copied formulas
 
Last edited:
Upvote 0
Code:
Sub copy_formula()Application.ScreenUpdating = False
    With ActiveSheet
    Set Rng = Range("a12:a24")
   Rng.copy
        For i = 2 To 50
           .Cells(12, i).PasteSpecial Paste:=xlPasteFormulas
        Next
 With Range("b12:ay24")
    .Value = .Value
    End With
    End With
   Application.ScreenUpdating = True
End Sub



Mohadin Sir Ji

Its Fantastic

Its working Great

Many Thanks Sir Ji
 
Upvote 0
In that case try
Code:
Sub Vishaal()
  Range("A12:A24").Copy Range("B12:AY24")
  Range("B12:AY24").Value = Range("B12:AY24").Value
End Sub
 
Upvote 0


Mohadin Sir Ji

In your code second work

With Range("b12:ay24")
.Value = .Value
End With
End With
Application.ScreenUpdating = True
End Sub

When its start working, excel hang and we need to restart

Can it is possible
1. It also work in loop as your code first part
2. In your code first part, code will first copy formula and paste and after that same time copy that coloumn and paste values

Pls help sir
 
Upvote 0
Well
I don't know what the formulas are in your sheet
and what is yous the excel version, here in 2013 work fine
Any way try

Code:
Sub
 copy_formula()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
    With ActiveSheet
    Set Rng = Range("a12:a24")
   Rng.Copy
        For i = 2 To 50
           .Cells(12, i).PasteSpecial Paste:=xlPasteFormulas
        Next
        Application.Calculation = xlCalculationAutomatic
 With Range("b12:ay24")
    .Value = .Value
    End With
    End With
   Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
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