You are here:

Excel/VBA for dragging down a formula


Report Tab
Report Tab  

i am trying to write a script that would drag down the formula in a table based on the number of entries in another worksheet column.

I have a table in table in A9:T:23 (row 9 us headers) on the worksheet "Report".  It is pulling data from another tab "S401 Tickets".  S401 tab is an ever growing database.  As additional data gets added to it, I want the user to be able to run a macro that will drag the formula in A10 of the table the total distance to grab all the data in column A of the "S401 Tickets" tab.

For example, currently the table on the "report" tab runs to row 23.  If 10 more rows of data get added to "S401 Tickets" I would like the Macro to pull the data down in column A of table to row 33.

Maybe this:

Option Explicit

Sub ExpandTable()
Dim LR As Long

LR = Sheets("S401 Tickets").Range("A" & Rows.Count).End(xlUp).Row

With Sheets("Report")
   .Range("A10:D10").AutoFill Destination:=.Range("A10:D" & LR + 10), Type:=xlFillDefault
End With

End Sub

About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Jerry Beaucaire


Excel Formulas, macros, automation. Microsoft Excel MVP - 2010. Code site with free code snippets and techniques:


Microsoft Excel MVP - 2010. I have my own extensive Excel help/code site: ===================== I have been offering free assistance as an Excel aid on many web sites for many years: ( - JBeaucaire) ======== ( - JBeaucaire) ======= ( - jbeaucaire)

Bachelor's Degree from Azusa Pacific University in Mathematics and Music Composition

Awards and Honors
Microsoft Excel MVP 2010

©2017 All rights reserved.