Copying formulas into all cells of a column Macro

Craig13_13

New Member
Joined
Apr 9, 2009
Messages
21
Hello Excel Gurus!

Hopefully I can explain my dilemma, a bit of background: it's a supplier score monthly tracker, very basic, list of suppliers in column A then Jan scores in column B, Feb scores in column C etc etc.

I've been working on Macros for arranging by score based on the last month using the (xlToRight) command, but I'm now working on a similar one try to copy a formula into every cell of the nerest blank column, for example if March (i.e. column D) is empty. I can get it to find the first empty column, I can get it to put the formula into that first cell but I can't get it to copy the formula into every cell of that column (bare in mind its not always going to be column D thats the empty one, thats why I'm using the xlToRight function). Can anyone help me with this?

Thanks very much!
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
see if something like this will work

Code:
Sub test()
    lastcol = Cells(2, Columns.Count).End(xlToLeft).Column
    lastrow = Cells(Rows.Count, lastcol).End(xlUp).Row
    Range(Cells(2, lastcol), Cells(lastrow, lastcol)).Copy Cells(2, lastcol + 1)
End Sub
 
Upvote 0
If your first data row is row 2 then (to get destination cell for pasteing) use

Range("IV2").Activate
Selection.End(xlToLeft).Offset(0, 1).Select
 
Upvote 0
a Perhaps better approach is

Code:
Sub Macro1()
'
Set MyDes = Range("IV2").End(xlToLeft).Offset(0, 1)
Range("B2:B5").Copy MyDes

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,178
Members
449,071
Latest member
cdnMech

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