Peter Groves

asked on

# Trouble inserting formula =IF(OR(ISNUMBER(AC3)=FALSE,AC3=0);0;AX3/AC3) into excel column via VBA

Having trouble inserting a formula into excel from access 2013 VBA.

this formula works if I put it directly in Excel

IF(OR(ISNUMBER(AC3)=FALSE;AC3=0);'N/A';AX3/AC3)

but when I try to put it there via VBA I've exhausted my tries!

With wks

.UsedRange 'Refresh UsedRange

Lastrow = .UsedRange.rows(.UsedRange.rows.Count).Row

this works (but with a ton of divide by zero errors!

.Range("BG3:BG" & Lastrow).Formula = "=AX3/AC3)"

This is what I want

.Range("BG3:BG" & LastRow).Formula = "=IF(OR(ISNUMBER(AC3)=FALSE;AC3=0);"N/A";AX3/AC3)"

I expect I'd need to get the quotation marks right!

I also tried things like

.Range("BG3:BG" & Lastrow).Formula = "=IF(OR(ISNUMBER(AC3)=FALSE,AC3=0);0;AX3/AC3)"

trying to eliminate the need for quotation modification just to see if that works! I could live with it if it did! But same error

application defined or object defined error 1004

Thankls

Pete

this formula works if I put it directly in Excel

IF(OR(ISNUMBER(AC3)=FALSE;

but when I try to put it there via VBA I've exhausted my tries!

With wks

.UsedRange 'Refresh UsedRange

Lastrow = .UsedRange.rows(.UsedRange

this works (but with a ton of divide by zero errors!

.Range("BG3:BG" & Lastrow).Formula = "=AX3/AC3)"

This is what I want

.Range("BG3:BG" & LastRow).Formula = "=IF(OR(ISNUMBER(AC3)=FALS

I expect I'd need to get the quotation marks right!

I also tried things like

.Range("BG3:BG" & Lastrow).Formula = "=IF(OR(ISNUMBER(AC3)=FALS

trying to eliminate the need for quotation modification just to see if that works! I could live with it if it did! But same error

application defined or object defined error 1004

Thankls

Pete

ASKER CERTIFIED SOLUTION

membership

This solution is only available to members.

To access this solution, you must be a member of Experts Exchange.

SOLUTION

membership

This solution is only available to members.

To access this solution, you must be a member of Experts Exchange.

ASKER

Thanks guys! I should have asked sooner! Burned several hours on this!

Pete

Pete

Formula can be simpler as well:

=IFERROR(AX3/AC3,NA())

=IFERROR(AX3/AC3,NA())

ASKER

IF(OR(ISNUMBER(AC3)=FALSE;

Pete