+ Reply to Thread
Results 1 to 3 of 3

Macros to input formaulas into a lot of cells. Formula has an IF statement

  1. #1
    Registered User
    Join Date
    04-30-2013
    Location
    Can
    MS-Off Ver
    Excel 2010
    Posts
    3

    Macros to input formaulas into a lot of cells. Formula has an IF statement

    Basically, I have 12ish rows and 10ish columns all requiring an IF statement formula that is slightly different. I am trying to make a macros to do it all for me but I am pretty new to Macros. Because the output of the IF statement is string, the quotation marks are confusing the entire formula. Also, as shown below, I am having difficulty using the (#,#) input method for cells to put in the Formula. Range.Formula does not work for me because the letter coordinate is changing. That is unless some one knows how to do A + 1 = B. Below is my code.

    Sub Create()
    Dim x As Integer
    Dim i As Integer
    Dim y As Integer
    Dim E As String

    x = 8
    i = 6
    y = 4

    For i = 6 To 16
    For x = 8 To 20
    Range(i, x).Formula = "=IF('Sheet2'!" & E & y & "=0,"","yes")"
    ' Want to put formula in Cell "i,x". Not sure how to change format from A1 to #,# in Range.
    ' Otherwise must use Cells(#,#) but not sure how to do Cells.Formula to work
    'IF statement simply does not work. Gets confused because of the additional quotation marks

    y = y + 1

    Next x

    x = 8
    Next i


    End Sub


    Thanks!
    Last edited by stylecrazy; 05-07-2013 at 05:47 PM.

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Macros to input formaulas into a lot of cells. Formula has an IF statement

    Please Login or Register  to view this content.
    I think I've got the reference wrong, but you get the idea.

    You have to put quotes around quotes.

    Look up 'RC reference' for more info.
    David
    (*) Reputation points appreciated.

  3. #3
    Registered User
    Join Date
    04-30-2013
    Location
    Can
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Macros to input formaulas into a lot of cells. Formula has an IF statement

    Thanks so much! It works great.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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