+ Reply to Thread
Results 1 to 3 of 3

Dynamic Autofill

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-14-2008
    Location
    Manchester, England
    MS-Off Ver
    2007
    Posts
    110

    Dynamic Autofill

    Hello

    You'll have to bear with me as not great at VBA. I want a formula to dynamically autofill in column G based on the contents of column F.

    I'm trying to use the following but it's not working.


    Sub CalcLengths()
    
        Dim lastrow As Long
    
        Range("G2").Select
        ActiveCell.FormulaR1C1 = "=RC[-5]*1"
        Selection.NumberFormat = "h:mm"
        
        lastrow = Cells(Rows.Count, "F").End(xlUp).Row + 1
        Selection.AutoFill Destination:=Range("G2" & lastrow), Type:=xlFillDefault
    
    End Sub
    Can anyone help please?

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644
    You don't say how the code doesn't work but try this.
    Sub CalcLengths()
    Dim lastrow As Long
    
        lastrow = Cells(Rows.Count, "F").End(xlUp).Row
    
        With Range("G2:G" & lastrow)
            .FormulaR1C1 = "=RC[-5]*1"
            .NumberFormat = "h:mm"
        End With
    
    End Sub
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    02-14-2008
    Location
    Manchester, England
    MS-Off Ver
    2007
    Posts
    110

    Re: Dynamic Autofill

    Works perfect!! Thanks

+ 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] VBA to AutoFill down dynamic columns
    By eorydc in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-11-2013, 03:36 PM
  2. [SOLVED] Dynamic Filetering and Autofill
    By 3nduranc3 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-14-2013, 10:34 AM
  3. Need help with dynamic autofill
    By oldmanexcel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-09-2013, 11:36 AM
  4. [SOLVED] Dynamic autofill VBA
    By Siglen in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-31-2012, 01:10 AM
  5. [SOLVED] autofill with dynamic lists
    By Pontus SWE in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-13-2005, 02:05 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