Thread
:
Macro How To
View Single Post
#
1
Posted to microsoft.public.excel.programming
Don Guillett
external usenet poster
Posts: 10,124
Macro How To
Sub pf1()
lr = Cells(Rows.Count, "A").End(xlUp).Row
Range("J9:j" & lr).Formula = _
"=IF(A9=""Appliances"",0,IF(OR(H9=""No Charge"",H9=""Not
Avail"",H9=""""),0,H9*0.1))"
End Sub
--
Don Guillett
SalesAid Software
"dread" wrote in message
...
Thank you Don. I changed it a little bit (see below) but it works. My
question now is how do I get this formula into all rows above the last row
where I have values in column "H".
To be a little more specific, I'm pasting information into the spreadsheet
starting at A9, but I don't know how many rows will contain information,
hence the ("H" & Rows.Count).End(xlUp). The Offset(1,2) is to put the
formula in column "J". I need the formula to be in J9 through the last
row
in column J where there is a value in column "H". (I hope this
explanation
makes sense).
Range("H" & Rows.Count).End(xlUp).Offset(1, 2).Formula =
"=IF(A9=""Appliances"",0,IF(OR(H9=""No Charge"",H9=""Not
Avail"",H9=""""),0,H9*0.1))"
Thanks again!
"Don Guillett" wrote:
try without r1c1. Notice double quotes
Range("J" & Rows.Count).End(xlUp).Offset(2).Formula = _
"=IF(A9=""Appliances"",0,IF(OR(H9=""No Charge"",H9=""Not
Avail"",H9=""""),0,H9*0.1))"
--
Don Guillett
SalesAid Software
"dread" wrote in message
...
I'm getting a run time error 1004 (application-defined or
object-defined
error) on the following line of code:
Range("J" & Rows.Count).End(xlUp).Offset(2).FormulaR1C1 =
"=IF(R9C:R[-1]C[-9]='Appliances',0,IF(OR(R9C:R[-1]C[-2]='No
Charge',R9C:R[-1]C[-2]='Not
Avail',R9C:R[-1]C[-2]=''),0,R9C:R[-1]C[-2]*0.1))"
I'm not too familiar with coding IF statements using FormulaR1C1
syntax,
but
the IF statement in the spreadsheet that I'm trying to replace with the
macro
is:
=IF(A9="Appliances",0,IF(OR(H9="No Charge",H9="Not
Avail",H9=""),0,H9*0.1))
Reply With Quote
Don Guillett
View Public Profile
Find all posts by Don Guillett