Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default 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
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
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Need syntax for RUNning a Word macro with an argument, called from an Excel macro Steve[_84_] Excel Programming 3 July 6th 06 07:42 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 11:34 PM.

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"