PDA

View Full Version : [SOLVED] Copy a formula on a worksheet by the number of data rows on a different sheet



Rickster_778
08-02-2005, 01:46 PM
I have a spread sheet that concatenates information from a different sheet that is downloaded. The down loaded information varies in the number of rows at each download. I need to have the script count the active rows and then move to the next spreadsheet and copy the concatenation formula down the same number of rows. ie data range A1:C302 (Row 1 being header) on downloaded sheet. Move to formula sheet and copy A2:C2 down to row 302, remembering the rows are variable from download to download and that next time there may be 305 rows or 275 rows.:dunno

Jacob Hilderbrand
08-02-2005, 06:29 PM
Here is an example.



Option Explicit

Sub AddFormulas()
Dim LastRow As Long
LastRow = Sheets("Sheet1").Range("A65536").End(xlUp).Row
Sheets("Sheet2").Range("B2").Copy Destination:=Sheets("Sheet1").Range("B2:B" & LastRow)
End Sub


Since you are working with multiple workbooks you will need to specify the workbook name before the sheet name.


Workbooks("Workbook1Name").Sheets("Sheet1").Range ...

Rickster_778
08-03-2005, 06:46 AM
Worked Great

Thanks......:bow: