Paste formula till the last column

vmjan02

Well-known Member
Joined
Aug 15, 2012
Messages
1,059
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
I have a sheet which has the formulas in cells A2, A3, A4, A5 till A30. all this cells have different formulas

Just need a vba code which will copy the formula till BA2, BA3,BA4,BA5 till BA30

Header starts form A1 till BA1
So it will copy the formula from A2 and paste it till BA2 ( till the last column)
and then convert it to values.

Any idea...
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
You meant like this?
VBA Code:
Sub Test()

Range("A1", "A30").Copy
Range("BA1").PasteSpecial (xlPasteFormulasAndNumberFormats)

End Sub
 
Upvote 0
I thought that you meant copy across all columns until the last column is reached?

BTW, I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

VBA Code:
Sub CopyFormulas()
  With Range("A2:A30")
    .Copy Destination:=.Resize(, Cells(1, Columns.Count).End(xlToLeft).Column)
  End With
End Sub
 
  • Like
Reactions: Zot
Upvote 0
Now I'm confused with last column with row :biggrin:
 
Upvote 0
You meant like this?
VBA Code:
Sub Test()

Range("A1", "A30").Copy
Range("BA1").PasteSpecial (xlPasteFormulasAndNumberFormats)

End Sub
I is working perfect

Just modified a bit

VBA Code:
Range("BK4:BK29").Copy
Range("BL4:DF4").PasteSpecial (xlPasteFormulasAndNumberFormats)
 
Upvote 0
I thought that you meant copy across all columns until the last column is reached?

BTW, I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

VBA Code:
Sub CopyFormulas()
  With Range("A2:A30")
    .Copy Destination:=.Resize(, Cells(1, Columns.Count).End(xlToLeft).Column)
  End With
End Sub
Thanks. This is all perfect..
 
Upvote 0

Forum statistics

Threads
1,214,942
Messages
6,122,367
Members
449,080
Latest member
Armadillos

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