+ Reply to Thread
Results 1 to 3 of 3

Thread: macro to copy formula to end of range

  1. #1
    Registered User
    Join Date
    10-06-2010
    Location
    Dunstable,England
    MS-Off Ver
    Excel 2010
    Posts
    93

    macro to copy formula to end of range

    Hi I have a worksheet with formula in F2 and G2. Column H is populated by data captured in a user form.

    I would like to program the form to copy the the formula down to the the last row in the range.

    For example if the user enters data and column H is then filled upto row 12 (this could be different every time) then I want the formula to copy down to row 12 in columns F and G!

    I hope that makes sense.Can anybody help?

    This is the code I have so far but it copys all the way down to the bottom of the work book,

    Many thanks
    Sub Macro6()  
    
     ' Macro6 Macro  
    
        Range("F2:G2").Select  
    
        Selection.AutoFill Destination:=Range("F2:G65536")  
    
         Range("F2:G65536").Select  
    
           
    
     End Sub

  2. #2
    Forum Guru jaslake's Avatar
    Join Date
    02-21-2009
    Location
    mineral city, ohio
    MS-Off Ver
    Excel 2007; Excel 2000
    Posts
    4,004

    Re: macro to copy formula to end of range

    Hi nods

    It'll probably be something like this
    Option Explicit
    Sub Macro6()
        Dim LR As Long
        LR = Range("H" & Rows.Count).End(xlUp).Row
        Range("F2:G2").Select
        Selection.AutoFill Destination:=Range("F2:G" & LR)
    End Sub
    John
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,639

    Re: macro to copy formula to end of range

    Does the userform enter one entry at a time?
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

+ 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.2.0