+ Reply to Thread
Results 1 to 6 of 6

Macro code for copying formulas till the last non-empty cell

  1. #1
    Registered User
    Join Date
    06-28-2013
    Location
    Budapest, Hungary
    MS-Off Ver
    Excel 2010
    Posts
    5

    Macro code for copying formulas till the last non-empty cell

    Hi All,

    I'd need a little help with assigning a range to my macro.

    What I need to do is the same as writing the formula to one cell, then doble click to the small cross at the bottom which automatically copies the formula to the last cell which is in a row that has values in the previous column.
    After recording the macro, this is what I get:

    Range("H2").Select
    Selection.AutoFill Destination:=Range("H2:H14")

    (obviously, I had 14 rows with values this time)
    What I'd like to have is a general formula for the selection described above, meaning if I have more rows than 14, the formula would still appear in the desired cell.

    Thanks in advance,
    Zoli

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro code for copying formulas till the last non-empty cell

    One way, but not auto, you need to run the code.

    Please Login or Register  to view this content.

  3. #3
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Macro code for copying formulas till the last non-empty cell

    Try this,

    Change the formula to suit.

    Please Login or Register  to view this content.
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro code for copying formulas till the last non-empty cell

    Or

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-27-2013
    Location
    Houghton, MI
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Macro code for copying formulas till the last non-empty cell

    If you just want a code that is similar to your first you can use the following.

    Please Login or Register  to view this content.
    It selects down to the last cell with it in a value from the initial cell you select, and then fills all those cells with the formula. Hope that helps!

  6. #6
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Macro code for copying formulas till the last non-empty cell

    Come on guys , is that all you got!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1