Autofill

  • Thread starter Thread starter dht
  • Start date Start date
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
 
To get the last cell in a worksheet use

ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell)


Sean
"Just press the off switch, and go to sleep!"
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top