+ Reply to Thread
Results 1 to 16 of 16

Fill Formula up to last empty adjacent Column

  1. #1
    Forum Contributor
    Join Date
    07-31-2012
    Location
    Cape Town South Africa
    MS-Off Ver
    Excel 2007
    Posts
    133

    Fill Formula up to last empty adjacent Column

    Hi All

    I know how to fill down to the last non-empty row using a macro like the following:

    Please Login or Register  to view this content.
    What about when you need to do it the other way round for columns instead or rows, can some-one assist with a macro.

    Thanks in advance

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Fill Formula up to last empty adjacent Column

    Is it the same formula that you need to copy, changing the column from 3 to 4, then to 5, etc?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Contributor
    Join Date
    07-31-2012
    Location
    Cape Town South Africa
    MS-Off Ver
    Excel 2007
    Posts
    133

    Re: Fill Formula up to last empty adjacent Column

    No, the macro I used is just an example and I have applied it in different situations, I would like to do the same column-wise even if the formula is a simple =sum(D12:D20), also need to know how to change it when the formula is an array.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Fill Formula up to last empty adjacent Column

    There are many ways to go about it.

    One of them could be - you could loop through the columns. You could also use the FormulaR1C1 method of inputting the formula and use it along with the loop to put the formula in.

  5. #5
    Forum Contributor
    Join Date
    07-31-2012
    Location
    Cape Town South Africa
    MS-Off Ver
    Excel 2007
    Posts
    133

    Re: Fill Formula up to last empty adjacent Column

    Is there a macro like:

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    07-31-2012
    Location
    Cape Town South Africa
    MS-Off Ver
    Excel 2007
    Posts
    133

    Re: Fill Formula up to last empty adjacent Column

    One of them could be - you could loop through the columns. You could also use the FormulaR1C1 method of inputting the formula and use it along with the loop to put the formula in.
    Dont understand what you mean by the above.

  7. #7
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Fill Formula up to last empty adjacent Column

    Try this
    Please Login or Register  to view this content.
    It will check for the last column based on what is populated in the 1st row.

    Then it loops populating each column. Note the formula also, has the i there to allow it to loop through the columns.

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Fill Formula up to last empty adjacent Column

    Quote Originally Posted by Floydlevedale View Post
    Dont understand what you mean by the above.
    You have used formula so you can directly put in in the vlookup formula like this
    Please Login or Register  to view this content.
    If you use FormulaR1C1 reference, the method of writing will be different. Instead of saying range A2, in formulaR1C1, you would be saying R[2]C if you are in the same column. Check it up online too and you will understand.

  9. #9
    Forum Contributor
    Join Date
    07-31-2012
    Location
    Cape Town South Africa
    MS-Off Ver
    Excel 2007
    Posts
    133

    Re: Fill Formula up to last empty adjacent Column

    Tried the macro, but it didnt work, I probably havent explained myself properly, so please see attached workbook, macro should do each worksheet in turn. The formula to fill in is highlighted in yellow.
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    07-31-2012
    Location
    Cape Town South Africa
    MS-Off Ver
    Excel 2007
    Posts
    133

    Re: Fill Formula up to last empty adjacent Column

    I need to do this daily and the workbook can have up to 20 worksheets, so a macro would save me loads of time

  11. #11
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Fill Formula up to last empty adjacent Column

    If you take sheet1, for which columns do you want the formula to be autofilled? Also will the formula always be in row 4?

  12. #12
    Forum Contributor
    Join Date
    07-31-2012
    Location
    Cape Town South Africa
    MS-Off Ver
    Excel 2007
    Posts
    133

    Re: Fill Formula up to last empty adjacent Column

    The number of columns will vary from wrksheet to wrksheet but max 18 columns, yes formula will always be in row 4

  13. #13
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Fill Formula up to last empty adjacent Column

    So will the formula be in the first column and it needs to be auto-filled uptil the last column?

  14. #14
    Forum Contributor
    Join Date
    07-31-2012
    Location
    Cape Town South Africa
    MS-Off Ver
    Excel 2007
    Posts
    133

    Re: Fill Formula up to last empty adjacent Column

    Yes, that's correct

  15. #15
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Fill Formula up to last empty adjacent Column

    Try this code
    Please Login or Register  to view this content.

  16. #16
    Forum Contributor
    Join Date
    07-31-2012
    Location
    Cape Town South Africa
    MS-Off Ver
    Excel 2007
    Posts
    133

    Re: Fill Formula up to last empty adjacent Column

    Thanks, work perfect now.

+ 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