Ad
Excel SQL Paste Formula Down In Column Based On Range Of Another Column
I have a spreadsheet that will populate data in Column A beginning at A2 from a table. Column A may be 10 rows or 150 Rows. I have a calculation in column F. I would like to Copy Down a formula in column F based on the number of Rows in Column A.
My code will copy a fixed range however I don't know how to make it dynamic based on the number of rows in column A.
Sheets("PriceAdjTemplate").Activate
Range("F2").Select
ActiveCell.Formula = "=(C2-E2)/C2"
Range("F2").Select
Selection.AutoFill Destination:=Range("F2:F350"), Type:=xlFillDefault
I would need to replace F350 with F & Number of rows in Column A Beginning with A2 Selection.AutoFill Destination:=Range("F2:F350"), Type:=xlFillDefault
Ad
Answer
using your coding approach, change the Selection.Autofill as follows:
Sheets("PriceAdjTemplate").Activate
Range("F2").Formula = "=(C2-E2)/C2"
Range("F2").Select
Selection.AutoFill Destination:=Range("F2:F" & Range("A2").End(xlDown).Row), Type:=xlFillDefault
Ad
source: stackoverflow.com
Related Questions
- → Trait 'IlluminateFoundationBusDispatchesJobs' not found
- → Laravel save CSV file error
- → Importing large CSV files in MySQL using Laravel
- → VBA how do I edit cell contents based on contents of two other cells in same row
- → How to work with PHPWord and LaravelExcel in Laravel 5.1 framework?
- → How to generate heading for columns?
- → VBA Excel run javascript form event
- → Reading excel file in Laravel
- → Remove Links on Excel after rendered from table2excel.js
- → Create JSON with through Excel Hierarchy
- → How to download fetch response in react as file
- → Laravel Excel big export. Server error 500
- → Download XLSX file on anchor link click in Laravel 5.2
Ad