On 5/20/2016 1:12 AM, Peter T wrote:
"Mike S" wrote in message
For n = 34 To 81
Cells(n, 4).Formula = "=IF(D31," & Cells(n, 2).Address & "
/" &
Cells(31, 4).Address & ", 0)"
Next
FWIW this would do the same
Cells(34, 4).Resize(81 - 34 + 1).Formula = "=IF($D$31," & Cells(34,
2).Address(0, 0) & "/ $D$31, 0)"
or this
addr0 = Cells(34, 4).Resize(81 - 34 + 1).Address ' could be
absolute or
relative
addr1 = Cells(31, 4).Address ' absolute
addr2 = Cells(34, 2).Address(False, False) ' R & C both relative
Range(addr0).Formula = "=IF(" & addr1 & "," & addr2 & "/" & addr1 &
",0)"
or
Range(Cells(34, 4), Cells(81, 4)).Formula = etc
IOW, if a formula can be "filled" it can be written in one go with
the
formula of the first cell
Peter T
Is this the same as copying and pasting the formula? If so I tried
that and maybe I did it incorrectly but it didn't work. I have a
single cell I divide the whole column of numbers by and the reference
to that cell got incremented every time I pasted the formula to a new
row. Maybe there's a different method of pasting that I'm not aware
of. I'll read up on the "resize" command to see what you're doing. I
never used or heard of ".address" before now either, so thank you adn
isabelle, I appreciate the tutoring.
You need an *absolute* ref to the single cell used by all cell
formulas. The "$" symbol in cell refs denotes absolute or relative...
$A$1 = fully absolute
$A1 = column absolute, row relative
A$1 = column relative, row absolute
A1 = fully relative
HTH
--
Garry
Free usenet access at
http://www.eternal-september.org
Classic
VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.
vb.general.discussion
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus