Macro Autofill

Khellian

New Member
Joined
Jul 29, 2011
Messages
5
Being new to Excel Macros I would appreciate some help in a small programming problem. I have a spreadsheet where I will be adding data on a daily basis. There is a date column with three additional columns where integers will be added, and a last column which will contain a formula that will calculate a value based on the three integers.

As each additional row will be new each day, I need to get a macro in place where by clicking on a button, the macro will find the last row in the formula column and then autofill down to the row below so that the formula is preserved and produces a result based on the new figures for that day.

I would greatly appreciate any advice. - Thanks in advance !
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi Khellian,

Welcome to MrExcel!!

A couple of initial queries:

• What is the Column housing the formula
• What is the formula

Thanks,

Robert
 
Upvote 0
If you have one of the latest Excel versions that has Tables you may want to consider converting your range in to a table. The formula(s) will automatically copy themselves down to the last row.

This may resolve your issue and there's no need for VBA.

Rob
 
Upvote 0
Welcome to the MrExcel board!

Are the additional values each day being added manually or by code? Further to R Pelle's comment, earlier versions have an option to 'Extend data range formats and formulas' that may also be some use to you.

So we need to know your Excel version and a bit more detail about just what is happening with your sheet and where things are in it.
 
Upvote 0
Thanks for the response guy - sorry I should have been clearer. The version that I have is from Office 2010 so it should have the latest features.

To answer Robert's question, in actual fact there are two cells that I want to auto fill with different formulae for both but I assume that the method for one would be similar for both.

One is "F6=B6/E6/D6" and the other is "G6=DAYS360(A6,$K$2)". Hence by entering data on the 7th. row for the date (A7) then three integer cells (B7,E7 and D7) I am looking for a way to automatically populate F7 and G7. My first thoughts were to use some macros but if there is a more efficient way that would be great.

Thanks again - David
 
Upvote 0
My first thoughts were to use some macros but if there is a more efficient way that would be great.
I think Rob has already given you a good suggestion:
If you have one of the latest Excel versions that has Tables you may want to consider converting your range in to a table. The formula(s) will automatically copy themselves down to the last row.

This may resolve your issue and there's no need for VBA.

Rob
If your data is something like mine below (not sure if you have something in column C or not) then

1. Select a cell in the table area

2. Go to the 'Insert' ribbon tab|Table|If Excel does not automatically select the current data area, then do so|ensure 'My table has headers' is checked|OK

A table should be created and as you enter data in the next row, the formulas should automatically populate into thet new row.

Excel Workbook
ABCDEFGHIJK
1DateInt 1OtherInt 2Int 3DivisionDays
223/07/111550.0415831/12/11
324/07/115830.2083157
425/07/116660.1667156
526/07/119390.3333155
627/07/113580.075154
728/07/115640.2083153
829/07/118970.127152
9
10
AutoFillFormulas
 
Upvote 0
Thanks for the instructions Peter - using them I created the table as you and Rob suggested. The format of the table that you showed in your reply is exactly the same as mine, however there must be something that I'm missing as the formulas are not in place when I add data into the next row. They still exist in the upper rows but the new row cell where the formula should be is blank. Is there a setting perhaps that I am missing somewhere?

thanks and regards

David
 
Upvote 0
I created the table as you and Rob suggested.
At this point ..

1. Did you get alternating blue rows all the way to the last row of existing data/formulas - and no further?

2. Were the formulas in columns F & G of that last row - and no further?


.. the formulas are not in place when I add data into the next row. id
Can you confirm that the "next row" you are reeferring to here was the first white row below the coloured table rows?
 
Upvote 0
Have a look at this example. Sometimes it's best to try out on a simple table before applying it to your own data just to get a feel for it.
As long as your "new data" is held within the table you should be fine.

Read Down and then Across :)



Rob.
 
Upvote 0
Thanks once again guys - I'm indebted to you all. I experimented with using tables and I think that that is the way to go. I'm experimenting with a few options that will make the formatting a little closer to what I was looking for. I recreated everything from scratch and now the table works as expected. However, when I created a number of additional rows at the bottom of the table that would allow me to add data without having to increase the size of the table, I found that the formula in the empty lines showed a divide by zero error. I got round that by using conditional formatting which when an error is displayed turns the color of the text to the same as the background - hence it is invisible. Another way would be to just increase the size of the table by dragging it down a row each time I put data in. Either way, this accomplishes what I was looking to do.

Many thanks again I appreciate your advice. !
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,740
Members
452,940
Latest member
rootytrip

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