ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Line in Macro doesn't work. (https://www.excelbanter.com/excel-programming/337569-line-macro-doesnt-work.html)

Valerie

Line in Macro doesn't work.
 
The following line in my macro won't work:

ActiveCell.FormulaR1C1 = "=IF(ISERROR(SEARCH(" -
",(RC[-7]))),(RC[-7]),-SUBSTITUTE((RC[-7])," - ",""))"

I have used the ActiveCell.Formula before but on little formulas. I want it
to write a formula in a cell that looks at a cell 7 columns to the left and
determine if it is text or not (imported data from SAP) and if it is text, I
want it to remove the "-" and put as a negative number.

I'm not very knowledgeable about VBA or macros. What I know is from what
I've copied from other recorded macros and pieced together.

Thanks for the help!!



Bob Phillips[_6_]

Line in Macro doesn't work.
 
ActiveCell.FormulaR1C1 = "=IF(ISERROR(SEARCH("" - ""," & _
"(RC[-7]))),(RC[-7])," & _
"-SUBSTITUTE((RC[-7]),"" - "",""""))"

when you have embedded quotes, you need to double-up.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Valerie" wrote in message
...
The following line in my macro won't work:

ActiveCell.FormulaR1C1 = "=IF(ISERROR(SEARCH(" -
",(RC[-7]))),(RC[-7]),-SUBSTITUTE((RC[-7])," - ",""))"

I have used the ActiveCell.Formula before but on little formulas. I want

it
to write a formula in a cell that looks at a cell 7 columns to the left

and
determine if it is text or not (imported data from SAP) and if it is text,

I
want it to remove the "-" and put as a negative number.

I'm not very knowledgeable about VBA or macros. What I know is from what
I've copied from other recorded macros and pieced together.

Thanks for the help!!





Valerie

Line in Macro doesn't work.
 
Thanks so much!!
V

"Bob Phillips" wrote:

ActiveCell.FormulaR1C1 = "=IF(ISERROR(SEARCH("" - ""," & _
"(RC[-7]))),(RC[-7])," & _
"-SUBSTITUTE((RC[-7]),"" - "",""""))"

when you have embedded quotes, you need to double-up.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Valerie" wrote in message
...
The following line in my macro won't work:

ActiveCell.FormulaR1C1 = "=IF(ISERROR(SEARCH(" -
",(RC[-7]))),(RC[-7]),-SUBSTITUTE((RC[-7])," - ",""))"

I have used the ActiveCell.Formula before but on little formulas. I want

it
to write a formula in a cell that looks at a cell 7 columns to the left

and
determine if it is text or not (imported data from SAP) and if it is text,

I
want it to remove the "-" and put as a negative number.

I'm not very knowledgeable about VBA or macros. What I know is from what
I've copied from other recorded macros and pieced together.

Thanks for the help!!







All times are GMT +1. The time now is 02:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com