Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default VB Macro writing a formula to a cell

I have a macro which is writing formulas to cells.
lines like: Range("D19").Formula = "=SUM(J23:J75)" work fine.

I am getting stuck on IF statements like the one below and
isolated it into the Formula_Test macro to 'play with'.

The facts a
L17 is general format cell.
The formula works fine in the worksheet when entered by hand.
Appropriate values are in F15 and F17.
The worksheet is NOT protected for this test.
I get a 1004 run time error when I run the macro.
The "If" help via function F1 key in Excel was little
help. I know the syntax of the formual is OK 'cuz it
works when entered by hand into L17.

Sub Formula_Test()
Application.ScreenUpdating = True
Range("L17").Formula = "=IF(F170,INT(F15/F17),"")"
End Sub

I don't know what to try or where to look next.
Help.
Thanks.
Neal Z
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default VB Macro writing a formula to a cell

If you use quotes within another set of quotes you need to double up so:

Sub Formula_Test()
Application.ScreenUpdating = True
Range("L17").Formula = "=IF(F170,INT(F15/F17),"""")"
End Sub

Regards
Rowan

Neal Zimm wrote:
I have a macro which is writing formulas to cells.
lines like: Range("D19").Formula = "=SUM(J23:J75)" work fine.

I am getting stuck on IF statements like the one below and
isolated it into the Formula_Test macro to 'play with'.

The facts a
L17 is general format cell.
The formula works fine in the worksheet when entered by hand.
Appropriate values are in F15 and F17.
The worksheet is NOT protected for this test.
I get a 1004 run time error when I run the macro.
The "If" help via function F1 key in Excel was little
help. I know the syntax of the formual is OK 'cuz it
works when entered by hand into L17.

Sub Formula_Test()
Application.ScreenUpdating = True
Range("L17").Formula = "=IF(F170,INT(F15/F17),"")"
End Sub

I don't know what to try or where to look next.
Help.
Thanks.
Neal Z

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default VB Macro writing a formula to a cell

It was late at night, thanks, i really did know that but didn't connect the
dots.
thanks again.
--
Neal Z


"Rowan" wrote:

If you use quotes within another set of quotes you need to double up so:

Sub Formula_Test()
Application.ScreenUpdating = True
Range("L17").Formula = "=IF(F170,INT(F15/F17),"""")"
End Sub

Regards
Rowan

Neal Zimm wrote:
I have a macro which is writing formulas to cells.
lines like: Range("D19").Formula = "=SUM(J23:J75)" work fine.

I am getting stuck on IF statements like the one below and
isolated it into the Formula_Test macro to 'play with'.

The facts a
L17 is general format cell.
The formula works fine in the worksheet when entered by hand.
Appropriate values are in F15 and F17.
The worksheet is NOT protected for this test.
I get a 1004 run time error when I run the macro.
The "If" help via function F1 key in Excel was little
help. I know the syntax of the formual is OK 'cuz it
works when entered by hand into L17.

Sub Formula_Test()
Application.ScreenUpdating = True
Range("L17").Formula = "=IF(F170,INT(F15/F17),"")"
End Sub

I don't know what to try or where to look next.
Help.
Thanks.
Neal Z


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
Need help writing Excel macro to solve a cell in each row of a spreadsheet Chris Excel Programming 5 September 10th 05 01:39 AM
Writing a macro to copy first cell down until next cell has data Gerald[_2_] Excel Programming 1 August 10th 05 10:06 PM
When writing a macro in excel workbook, how do I refer to ea cell Diana Bartz Excel Programming 1 July 7th 05 09:51 PM
I need help writing a macro to replace cell contents. (new to VB) Emoshag[_2_] Excel Programming 2 April 14th 05 07:47 AM
Writing variable from a Macro to a Cell Parker[_3_] Excel Programming 5 September 28th 03 03:47 AM


All times are GMT +1. The time now is 04:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"