Macro: Fill down then stop

XLerator

New Member
Joined
Apr 10, 2002
Messages
21
How do I create a code in which after inserting a column and typing in a formula, it FILLS IT DOWN, but STOPS with the LAST row of text---each day I run the macro the number of rows would be different, so the formula would have to stop on that row...the rows below it are all blank.

Is there a way?
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Hi
This little macro would enter your formula in C1, count used rows by Column B, and then fill down column C.

Edit to suit by replacing the formula with the one you need and also the column used for criteria/row count.

Sub FillDown()
Dim LastRow As Long
Range("C1").Formula = "=Sum(A1+B1)"
LastRow = Range("B1:B" & Range("B1").End(xlDown).Row).Rows.Count
Range("C1" & ":C" & LastRow).FillDown
End Sub

Tom

P.S.
I did not read your post as clearly as I should have. You are adding a column.
I would use another line of code with this variable to find the column you need to place the formula in:

LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column

If you need more detailed help, please re-post.

Thanks,
Tom
This message was edited by TsTom on 2002-04-15 21:54
 
Upvote 0
Hello XLerator. Hi Tom!
Here is similar way.
The layout I assumed are the same as Tom's.
Formulas would be written to the specific range directly.

Sub Test()
Range("C1", Range("B65536").End(xlUp).Offset(, 1)).Formula = "=A1+B1"
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,422
Messages
6,119,395
Members
448,891
Latest member
tpierce

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