Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Drag formula down till last row

Posted on 2012-04-05
4
Medium Priority
?
5,640 Views
Last Modified: 2012-04-05
Hello All,
I need a vba code in excel that does the following trick.
The code copies the formula in the last two columns (F10, G10) down to the last row when refresh is clicked. If I add a new row at the end, the last two columns formulas don’t work properly. Only when I re-copy the top cell g10 and drag it down to G19, then it works again.
So the idea of the refresh button (when I click it) is to copy the formulas from the first cell in the G column to the last recent end cell in that column. The copy will happen till it reaches the last row value in C column

Thank you
copy-formulas-down-depending.xlsx
0
Comment
Question by:Rayne
  • 2
4 Comments
 
LVL 10

Expert Comment

by:Anthony Berenguel
ID: 37814332
Rayne,

take a peak at the attached link. I believe that will get you started in the right direction.
vba to fill down formulae just in rows that hold data

Good luck!
0
 
LVL 35

Accepted Solution

by:
Norie earned 2000 total points
ID: 37814369
Try this.
Sub CheckBox1_Click()
Dim LastRow As Long

    LastRow = Range("C" & Rows.Count).End(xlUp).Row
    
    Range("F10:G10").Copy Range("F10:G" & LastRow)
    
End Sub

Open in new window

0
 

Author Comment

by:Rayne
ID: 37814434
Thank you imnorie, That looks awesome.
0
 

Author Closing Comment

by:Rayne
ID: 37814436
quick help
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lost Word File? Eagerly, need it back? Read ahead; this File Recovery guide is for you.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question