Results 1 to 7 of 7

How to programmatically (VBA macro) set the contents of a cell to be a formula ?

Threaded View

rex99 How to programmatically (VBA... 12-10-2012, 10:22 AM
watersev Re: How to programmatically... 12-10-2012, 11:24 AM
MarvinP Re: How to programmatically... 12-10-2012, 11:31 AM
rex99 Re: How to programmatically... 12-11-2012, 08:16 PM
jimmalk Re: How to programmatically... 12-11-2012, 09:18 PM
watersev Re: How to programmatically... 12-12-2012, 05:43 AM
rex99 Re: How to programmatically... 12-16-2012, 08:15 PM
  1. #1
    Registered User
    Join Date
    11-05-2012
    Location
    NY
    MS-Off Ver
    Excel 2003
    Posts
    13

    How to programmatically (VBA macro) set the contents of a cell to be a formula ?

    How would I programmatically (within a VBA macro) set the contents of a cell to be a formula ?

    For example, I know I can set a cell to the contents of a string, by doing

    Sheets("Out").Cells(row, col) = str
    I tried something like

    Sheets("Out").Cells(11, col) = "=IF(NOT( ISBLANK(F11) ), IF(F11<E11,-(E11-F11),F11-E11), "")"
    but that of course didn't work.

    The formula

    Formula: copy to clipboard
    =IF(NOT( ISBLANK(F11) ), IF(F11<E11,-(E11-F11),F11-E11), "")


    works for me, but I want to be able to programmatically place it in a cell, while incrementing the cell references in the formula ... IE: E11, F11 .... E12, F12, .... E13, F13 .......

    Thanks
    Last edited by jeffreybrown; 12-10-2012 at 10:24 AM. Reason: Please use code tags...Thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1