+ Reply to Thread
Results 1 to 20 of 20

VBA to fill formula down till last row in column.

Hybrid View

hkbhansali VBA to fill formula down till... 07-12-2018, 10:57 AM
PCI Re: VBA to fill formula down... 07-12-2018, 11:20 AM
hkbhansali Re: VBA to fill formula down... 07-12-2018, 11:29 AM
Fluff13 Re: VBA to fill formula down... 07-12-2018, 11:28 AM
hkbhansali Re: VBA to fill formula down... 07-12-2018, 11:34 AM
Fluff13 Re: VBA to fill formula down... 07-12-2018, 11:37 AM
hkbhansali Re: VBA to fill formula down... 07-12-2018, 12:04 PM
hkbhansali Re: VBA to fill formula down... 07-12-2018, 12:38 PM
Fluff13 Re: VBA to fill formula down... 07-12-2018, 12:47 PM
Winon Re: VBA to fill formula down... 07-12-2018, 12:47 PM
PCI Re: VBA to fill formula down... 07-12-2018, 11:43 AM
PCI Re: VBA to fill formula down... 07-12-2018, 12:20 PM
hkbhansali Re: VBA to fill formula down... 07-12-2018, 12:37 PM
Winon Re: VBA to fill formula down... 07-12-2018, 12:44 PM
hkbhansali Re: VBA to fill formula down... 07-12-2018, 01:31 PM
Winon Re: VBA to fill formula down... 07-12-2018, 01:00 PM
Fluff13 Re: VBA to fill formula down... 07-12-2018, 02:26 PM
PCI Re: VBA to fill formula down... 07-12-2018, 01:20 PM
PCI Re: VBA to fill formula down... 07-12-2018, 02:56 PM
Winon Re: VBA to fill formula down... 07-12-2018, 04:27 PM
  1. #1
    Forum Contributor
    Join Date
    12-21-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    398

    VBA to fill formula down till last row in column.

    Hi,

    I'm working on a project and I'm trying to get my VBA code to draw down the formula that's in cell "U3" all the way down to the end of the data set.
    I'm using column "A".

    I want to copy formula with userform command button.

    example: If There are values till cell "A3:A25" then I want to copy formula in column "U3:U25",

    and when user Add Data in column "A" in "A26:A36 and hit command button same formula copy in column "U26:U36.

    So in excel my formula in cell "U3" is =G3&","&L3.

    Thanks.
    My English is very poor, so please be patient >_<"

    Thanks & Regards.
    hkbhansali

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: VBA to fill formula down till last row in column.

    See next code
    Option Explicit
    Sub FillDown()
    Const FR  As Integer = 3
    Const RefCol As String = "A"
    Const WkCol As String = "U"
    Dim LR  As Integer
    Dim WkRg  As Range
        LR = Cells(Rows.Count, RefCol).End(3).Row
        Set WkRg = Range(Cells(FR, WkCol), Cells(LR, WkCol))
        WkRg.FillDown
    End Sub
    - Battle without fear gives no glory - Just try

  3. #3
    Forum Contributor
    Join Date
    12-21-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    398

    Re: VBA to fill formula down till last row in column.

    Hi PCI,

    Above code I have copy in module and run it but nothing happen!!!

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,791

    Re: VBA to fill formula down till last row in column.

    Another option
    Sub FillFormula()
    Range(Range("U" & Rows.Count).End(xlUp), Range("A" & Rows.Count).End(xlUp).Offset(, 20)).FillDown
    End Sub

  5. #5
    Forum Contributor
    Join Date
    12-21-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    398

    Re: VBA to fill formula down till last row in column.

    Hi Fluff13,

    I have copy CODE in module and run it but nothing happen!!!

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,791

    Re: VBA to fill formula down till last row in column.

    Is the sheet you want the code to work on, the active sheet?
    If not what is the sheet name?

  7. #7
    Forum Contributor
    Join Date
    12-21-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    398

    Re: VBA to fill formula down till last row in column.

    Yes, I work on active sheet..sheet name is "Summary"

  8. #8
    Forum Contributor
    Join Date
    12-21-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    398

    Re: VBA to fill formula down till last row in column.

    Hi Fluff13

    Sorry, your code works fine, it was my mistake row "A450:U450" was merge and I have unmerge it and code works fine.

    thanks alot and I realy apologies .

  9. #9
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,791

    Re: VBA to fill formula down till last row in column.

    Quote Originally Posted by hkbhansali View Post
    Sorry, your code works fine, it was my mistake row "A450:U450" was merge and I have unmerge it and code works fine.

    thanks alot and I realy apologies .
    Glad we could help & thanks for the feedback

  10. #10
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA to fill formula down till last row in column.

    It is not necessary to use FillDown in the Code.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  11. #11
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: VBA to fill formula down till last row in column.

    Can you first run the macro without any button or others:
    Select the sheet to treat
    Launch the macro
    What's happen ??

  12. #12
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: VBA to fill formula down till last row in column.

    Yes, I work on active sheet..sheet name is "Summary"
    So when launching the macro from developer ...what is the result ?

  13. #13
    Forum Contributor
    Join Date
    12-21-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    398

    Re: VBA to fill formula down till last row in column.

    Hi PCI,

    Sorry, your code works fine, it was my mistake row "A450:U450" was merge and I have unmerge it and code works fine.

    thanks alot and I realy apologies .

  14. #14
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA to fill formula down till last row in column.

    Hello hkbhansali,

    Similar to what Fluff13 has suggested, this will also work.

    Option Explicit
    Sub Group()
    
      Range("U3:U" & Range("A" & Rows.Count).End(xlUp).Row).Formula = "=G3&"",""&L3"
       Range("U3:U" & Range("A" & Rows.Count).End(xlUp).Row).Value = Range("U3:U" & Range("A" & Rows.Count).End(xlUp).Row).Value
    
      End Sub
    Regards.
    Last edited by Winon; 07-12-2018 at 04:20 PM.

  15. #15
    Forum Contributor
    Join Date
    12-21-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    398

    Re: VBA to fill formula down till last row in column.

    Helllo Winon,

    First line of your code mark Red Colour (Error)
    Range("U3:U" & Range("A" & Rows.Count).End(xlUp).Row).Formula = "=G3&","&L3"
    Last edited by hkbhansali; 07-12-2018 at 01:34 PM.

  16. #16
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA to fill formula down till last row in column.

    @ Fluff13,

    Nice going Fluff13.

    Try my Code to eliminate FillDown.

    Regards.

  17. #17
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,791

    Re: VBA to fill formula down till last row in column.

    Quote Originally Posted by Winon View Post
    @ Fluff13,

    Nice going Fluff13.

    Try my Code to eliminate FillDown.

    Regards.
    Once I add the extra " to your code
    "=G3& "","" &L3"
    It worked fine
    I just felt that FillDown was easier

  18. #18
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: VBA to fill formula down till last row in column.

    Try my Code to eliminate FillDown
    What is the benefit ?

  19. #19
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: VBA to fill formula down till last row in column.

    Thanks you hkbhansali, for the rep.

  20. #20
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA to fill formula down till last row in column.

    Hi hkbhansali,

    Yes you are right.

    Sorry, my bad!

    The correct Code is shown below.

    Option Explicit
    Sub Group()
    
      Range("U3:U" & Range("A" & Rows.Count).End(xlUp).Row).Formula = "=G3&"",""&L3"
       Range("U3:U" & Range("A" & Rows.Count).End(xlUp).Row).Value = Range("U3:U" & Range("A" & Rows.Count).End(xlUp).Row).Value
    
      End Sub
    @ PCI,

    What is the benefit ?
    Much less lines and no need to tell the system to do what it will be doing in any case.

    @ Fluff13,

    Good catch! I forgot to add the extra quotes as required by VBA. Big mistake!

    Regards.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] copy formula and fill down till last not blank cells
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-11-2017, 07:24 AM
  2. [SOLVED] Need vba to fill format the datevalue in column right till end of value and formula across
    By johnmacpro in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-01-2016, 10:07 AM
  3. [SOLVED] VBA to fill the formula across row and column till total
    By johnmacpro in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-13-2016, 09:25 AM
  4. [SOLVED] VBA to fill the formula in every set of range till end of row data
    By johnlara in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-30-2016, 10:50 AM
  5. [SOLVED] VBA to fill formula down till last row in column
    By Wither125 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-25-2016, 06:03 PM
  6. Sum till the column till the date match
    By ursanil in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-02-2014, 06:29 AM
  7. Help with Macro: I need to fill columns D-N only up till the row number in column A
    By zizou0178 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-19-2014, 02:16 PM

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