View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
davy_gravy davy_gravy is offline
external usenet poster
 
Posts: 11
Default Macro fill down question, I think its easy

Hi,

try this:

if you've got data in A1:a20, and you want to put formulas (the same
one) in b1:b20

lastrow = range("a1").end(xldown).row ' this is to find the last row
with data
range("b1").select
activecell.formula = "=a1*200" 'or whatever your formula is
activecell.copy
do
activecell.offset(1,0).select 'to select the next cell down
activesheet.paste
loop until activecell.row = lastrow

hopefully this gives you a start in the right direction.

Dave

Still Learning wrote:
My macro works, but its slow, I'm trying to speed it up and there's a very
obvious way to do that.

Right now my macro fills down formulas numerous times, the problem is it
fills down to the bottom of the sheet. How can I set the range so when I
fill down it goes to the bottom of the data instead of the bottom of the
sheet (it would work great if I could get it to fill down to the first row
that doesn't have any data in it).

Right now here is an example of what I have, note how it fills down to the
bottom of the spreadsheet:

Range("A3:C3").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FillDown

Is there just a snipet of vb that I could replace the range selection line
with that would work?