+ Reply to Thread
Results 1 to 8 of 8

VB Formula error in macro, How to Continue?

  1. #1
    Registered User
    Join Date
    04-29-2008
    Location
    Texas
    Posts
    4

    Unhappy VB Formula error in macro, How to Continue?

    Ok. I have a formula filling down a column and I want to replace the formula if the initial formula errors (#VALUE) with an If statement?

    If ActiveCell = "#VALUE" Then
    ActiveCell.FormulaR1C1 = "=(RC[-16])"

    Obviously it doesn't work like that. Inserting If(iserror( exceeds 7 IF(s). How do I replace a formula error to continue with a correct value using an alternate formula other than writing more code to look for these errors later?

    Any help will be appreciated and valued. Thank you in advance.

    Mikeco

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Please Login or Register  to view this content.
    Please edit your post to add code tags.

  3. #3
    Registered User
    Join Date
    04-29-2008
    Location
    Texas
    Posts
    4

    Used more code to fix formula...

    Well, I can't stop thinking about it so I added maybe 5 or more extra lines to solve this and move forward.

    ActiveCell.FormulaR1C1 = "=IF(ISERROR(RC[-1]),1,0)"
    If ActiveCell = 1 Then
    Selection.ClearContents
    ActiveCell.Offset(0, -1).Range("A1").Select
    Selection.ClearContents
    ActiveCell.FormulaR1C1 = "=RC[-16]"
    End If
    If ActiveCell = 0 Then
    Selection.ClearContents
    ActiveCell.Offset(0, -1).Range("A1").Select
    End If
    ActiveCell.Offset(1, 0).Range("A1").Select

    If there was a better way, I'd still appreciate the tip and thank you.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Mikeco, mon frere, please read the Forum Rules, particularly about the use of Code Tags, and then edit your posts to add them.
    Last edited by shg; 04-30-2008 at 12:46 AM.

  5. #5
    Registered User
    Join Date
    04-29-2008
    Location
    Texas
    Posts
    4

    Red face Add code tags to my post!!

    Quote Originally Posted by Mikeco
    Well, I can't stop thinking about it so I added maybe 5 or more extra lines to solve this and move forward.
    Please Login or Register  to view this content.
    If there was a better way, I'd still appreciate the tip and thank you.
    How is this to short to submit? (added, getting < then 10 charaters error)
    MikeCo

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Mike, please back up a little to describe what you're trying to do overall, rather than describing how to fix what doesn't work.

  7. #7
    Registered User
    Join Date
    04-29-2008
    Location
    Texas
    Posts
    4

    shg Resolved - Issue Closed

    shg,

    You resolved my issue. I "quote" my post to add "code" tags. I do not have the option to "edit" my posts that do not have "code" tags.

    I used your suggested code and works fine. Thanks.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    You got the message on code tags, thank you, Mike.

    Glad you got it sorted out -- I don't feel like I contributed much. Onward and upward.

+ 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