Copy Formula down for Gord Dibben

P

PCOR

Thanks. That looks good.BUT I could use a small change....
How would I go about using this VBA code so that the formula would be copied
to any two col to the right of the selected column.

Ian
Ian

How about VBA?

Sub copydown()
Dim Lrow As Long
Lastrow = Range("A" & Rows.Count).End(xlUp).Row
Range("B1:C" & Lastrow).FillDown
End Sub

Will copy formulas in B1 and C1 down as far as you have data in Column A

Gord

No dog lol
It would depend on how many entries there were on any given days.
Ian
Gord Dibben said:
PCOR

Still short on details.

How would you(or anyone) know when it should be 25, 300 or 1000?

There has to be some type of determining factor as in "if the dog barks twice,
copy down 25 cells" or "if I get lucky tonight copy down 300 cells"

Gord


May be word variable is misleading.
Some days I will have to copy the formula down 25 cells others 300 and other
could be 1000
It may never be the same
Thanks

"Gord Dibben" <gorddibbATshawDOTca> wrote in message
PCOR

What determines the variable?

If it is the data in an adjacent column, just double-click on the
fill-handle
of the cell with the formula to fill down to end of data in the adjacent
column.

Fill-handle is the little black square on the lower-right corner of the
cell.

If variable is something else, post back. You will probably need code.

Gord Dibben XL2002
 
G

Gord Dibben

Ian

Sorry not to get back earlier. There are better ways to do this but this one
works.

If data in activecell column is contiguous(no blanks)...........

Sub Auto_Fill()
Dim Lrow As Long
Lrow = ActiveCell.End(xlDown).Row
ActiveCell.Offset(0, 1).Range("A1:B1").Select
Selection.AutoFill Destination:=ActiveCell.Range("A1:B" & Lrow)
End Sub

Don't worry about the A1:B1. Excel knows where it is.

Gord

Thanks. That looks good.BUT I could use a small change....
How would I go about using this VBA code so that the formula would be copied
to any two col to the right of the selected column.

Ian
Ian

How about VBA?

Sub copydown()
Dim Lrow As Long
Lastrow = Range("A" & Rows.Count).End(xlUp).Row
Range("B1:C" & Lastrow).FillDown
End Sub

Will copy formulas in B1 and C1 down as far as you have data in Column A

Gord
 

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

Top