+ Reply to Thread
Results 1 to 5 of 5

Fill formulas to last row containing data.

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Fill formulas to last row containing data.

    Hello everyone. I would like to extend the fomulas in columns AP, AQ, and AT to the last row of data. Currently I paste (via a macro) data from two seperate files into a workbook that acts as a template where the formulas in columns AP, AQ and AT are extended "far down". I would like to stop doing that and simply extend the formulas via code. Any suggestions? Below is my code that I am working with. The formuals are extended in the worksheet called "...Valuation Tool"


    Option Explicit
    Public Sub CommandButton1_Click()
        Dim CurrentDate As String
        Dim PriorDate As String
        Dim WrkbookPrior As Workbook
        Dim WrkbookCurrent As Workbook
        Dim FilePath1 As String
        Dim FileNamePrefix1 As String
        FileNamePrefix1 = "Option EPMS Valuation "
        FilePath1 = "C:\Users\AHernandez1\Desktop\"
        
    With Workbooks.Open(FilePath1 & "Option EPMS Valuation " & Format(TextBoxPriorDate.Text, "m-dd-yy") & ".xlsx")
        .Sheets("Page1-1").Range("A:AO").Copy Workbooks("Option EPMS Valuation Tool.xlsm").Sheets("Prior_Quarter").Range("A1")
    End With
    
    With Workbooks.Open(FilePath1 & LCase(FileNamePrefix1) & Format(TextBoxCurrentDate.Text, "m-dd-yy") & ".xlsx")
       .Sheets("Page1-1").Range("A:AO").Copy Workbooks("Option EPMS Valuation Tool.xlsm").Sheets("Current_Quarter").Range("A1")
    End With
    
    Workbooks("Option EPMS Valuation Tool.xlsm").Sheets(1).Range("R:R").NumberFormat = "#,##0.00" 'Format to a number
    Workbooks("Option EPMS Valuation Tool.xlsm").Sheets(1).Range("AP:AP").NumberFormat = "#,##0.00" 'Format to a number
    'WrkbookPrior.Close False
    'WrkbookCurrent.Close False
    
        
    End Sub
    Last edited by AnthonyWB; 06-27-2011 at 12:05 AM.

  2. #2
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Fill formulas to last row containing data.

    This is somewhat modified from another post. Any other suggestions?

    Sub Fill_Formulas_To_Last_Row_With_Data()
    '----------------------------------------------------------
    Dim Last_Row As Integer
    '----------------------------------------------------------
    With Workbooks("Option EPMS Valuation Tool.xlsm")
         Last_Row = Range("A" & Rows.Count).End(xlUp).Row
         Range("AP2").AutoFill Destination:=Range("AP2:AP" & LR), Type:=xlFillDefault
         Range("AQ2").AutoFill Destination:=Range("AQ2:AQ" & LR), Type:=xlFillDefault
         Range("AR2").AutoFill Destination:=Range("AR2:AQ" & LR), Type:=xlFillDefault
        End With
    End Sub

  3. #3
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Fill formulas to last row containing data.

    Correction:

    Sub Fill_Formulas_To_Last_Row_With_Data()
    '----------------------------------------------------------
    Dim Last_Row As Integer
    '----------------------------------------------------------
    With Workbooks("Option EPMS Valuation Tool.xlsm")
         Last_Row = Range("A" & Rows.Count).End(xlUp).Row
         Range("AP2").AutoFill Destination:=Range("AP2:AP" & Last_Row ), Type:=xlFillDefault
         Range("AQ2").AutoFill Destination:=Range("AQ2:AQ" & Last_Row ), Type:=xlFillDefault
         Range("AR2").AutoFill Destination:=Range("AR2:AQ" & Last_Row ), Type:=xlFillDefault
        End With
    End Sub

  4. #4
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Fill formulas to last row containing data.

    Anyone have any ideas on this?

  5. #5
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Fill formulas to last row containing data.

    I got it !

+ 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