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!
 

TheNoocH

Well-known Member
Joined
Oct 6, 2004
Messages
3,482
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
 

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,453
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
 

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,453
a Perhaps better approach is

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

End Sub
 

Forum statistics

Threads
1,081,749
Messages
5,361,064
Members
400,611
Latest member
ThebigG

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top