#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Autofill

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Autofill

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!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Autofill

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
--
Regards,
Tom Ogilvy


"dht" wrote in message
...
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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Autofill

Thanks for the response.
Got it sorted now

Cheers


"Tom Ogilvy" wrote in message
...
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
--
Regards,
Tom Ogilvy


"dht" wrote in message
...
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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autofill [email protected] Excel Worksheet Functions 3 November 7th 08 07:53 AM
AutoFill Amy Excel Discussion (Misc queries) 1 October 20th 05 08:09 PM
Autofill? Amateur Excel Discussion (Misc queries) 3 September 9th 05 07:46 PM
Autofill: Need to autofill one week block, (5) weekday only into cells. dstock Excel Discussion (Misc queries) 1 June 17th 05 08:21 PM
Q. Autofill question: Can I autofill alpha characters like I can numbers? George[_22_] Excel Programming 5 August 7th 04 10:33 AM


All times are GMT +1. The time now is 03:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"