Autofill

D

dht

Hi,

I'm trying to write a VBA code that imports a dataset (for example lines of
data in rows A to G), I've managed this fine. Then in the column to the left
of the data (column H) writes an equation that is then filled/copied to the
left of every row with data in it. Can anyone shed some light on how to
identify what the last row is (I have a column that is guaranteed to hold
data (A) for the whole data set) and how to copy the equation to the last
row.

Thanks
Dave
 
S

Sean

To get the last cell in a worksheet use

ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell)


Sean
"Just press the off switch, and go to sleep!"

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
T

Tom Ogilvy

set rng = Range(Cells(1,"G"),Cells(rows.count,"G").End(xlup))
rng.offset(0,1).Formula = "=sum(A1:G1)"
' and if you really need the row number
lastrow = rng.rows(rng.rows.count).row
msgbox "Last row is " & lastrow
 
Top