+ Reply to Thread
Results 1 to 6 of 6

Formula Scripts

  1. #1
    Registered User
    Join Date
    01-27-2007
    Posts
    18

    Formula Scripts

    What is wrong with the following formulas:

    'formula for column G
    With Me.Range("G" & currRow)
    Me.Range("G" & currRow).Formula = "=IF(E" & currRow & "= 0, 0, (RC[-2]/RC[-3]))"
    End With

    formula for column I
    With Me.Range("I" & currRow)
    Me.Range("I" & currRow).Formula = "=IF(H" & currRow & " = 0, 0, RC[-5]-(((1-RC[1])*RC[-5])+RC[-4]))"
    End With

    Thanks,

    TB

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885
    Do you have 'currRow' setup somewhere to be set to the value of the current row? I would think you need to reference ROW() instead.

    Or, I could be off my rocker.

  3. #3
    Registered User
    Join Date
    01-27-2007
    Posts
    18

    Definint currRow

    Here is where currRow is defined:

    Private Sub CommandButton1_Click()
    Dim currRow As Long
    ActiveCell.Activate
    currRow = ActiveCell.Row
    uChoose = MsgBox("Insert new row at " & currRow & "?", vbYesNo, "Please confirm ...")
    If uChoose = vbNo Then Exit Sub
    'insert new row
    Me.Rows(currRow).Insert

  4. #4
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by TjBoiler
    Here is where currRow is defined:

    Private Sub CommandButton1_Click()
    Dim currRow As Long
    ActiveCell.Activate
    currRow = ActiveCell.Row
    uChoose = MsgBox("Insert new row at " & currRow & "?", vbYesNo, "Please confirm ...")
    If uChoose = vbNo Then Exit Sub
    'insert new row
    Me.Rows(currRow).Insert
    try
    Please Login or Register  to view this content.
    - you are switching r1c1 and A1 formatting on the same row.

    hth
    ---
    Si fractum non sit, noli id reficere.

  5. #5
    Registered User
    Join Date
    01-27-2007
    Posts
    18

    Thanks

    Ok that works! Thank you again, Brian! I have couple questions I hope you don't mind answering.

    1. Why do you have to use 1-J rather than using H?
    2. If I wanted to use A1 formatting could I have put .formulaR1C1?

    I am just learning these items. I appreciate your patience.

    Thanks,

    TB

  6. #6
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by TjBoiler
    Ok that works! Thank you again, Brian! I have couple questions I hope you don't mind answering.

    1. Why do you have to use 1-J rather than using H?
    2. If I wanted to use A1 formatting could I have put .formulaR1C1?

    I am just learning these items. I appreciate your patience.

    Thanks,

    TB
    Hi,

    1-J is incorrect if you intended H, use H

    use .formula if you are entering A1 format formula

    use .formulaR1C1 if you are entering r1c1 formula, but don't mix the two.

    also, where you said 'With' you can use .formula until the End With to refer to that cell.

    hth
    ---

    added, noted that your ortiginal formula did

    =IF('H5' = 0, 0, D5-(((1-J5)*D5)+E5))

    my translation does

    =IF(H5 = 0, 0, D5-((1-J5)*D5+E5))

    which looks reasonably similar.

    ---
    Last edited by Bryan Hessey; 02-09-2007 at 12:14 AM.

+ 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