Solved

add one or more characters to the end of all selected cells in excel

Posted on 2013-06-10
3
273 Views
Last Modified: 2013-06-10
I am trying to change the formula in a selected area of an excel 2010 spreadsheet to include the expression iferror(*," ").  Where * is any expression currently to the right of the = sign.  In other words I would want to change =f8 to =iferror(f8," ").   I can figure out how to put 'iferror(' after the = sign by search and replace (and first puting ' in front so it doesn't execute, then getting rid of the ' once I am finished).  I can't figure out a way to tack the
expression ," ") to the end of every expression.  I assume some method using wildcards might work.  I don't really want to write a VB script.  But if thats the only way to do it, then I would be happy to listen to how to use that.
0
Comment
Question by:dma70
  • 2
3 Comments
 
LVL 81

Expert Comment

by:zorvek (Kevin Jones)
ID: 39235743
Wildcards won't help in this case since the replace function does not understand the notion of "include in the replace string the part covered by the wildcard character(s)".

You will have to use a VBA macro to do the work.

Kevin
0
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 400 total points
ID: 39235769
A macro to do the work:

Public Sub AddErrorHandling()

    Dim Cell As Range
   
    For Each Cell In Selection
        If Cell.HasFormula Then
            If Not Left(Cell.Formula, 9) = "=IFERROR(" Then
                Cell.Formula = "=IFERROR(" & Mid(Cell.Formula, 2) & ","""")"
            End If
        End If
    Next Cell

End Sub

Kevin
0
 
LVL 1

Author Closing Comment

by:dma70
ID: 39235840
works great - thank you
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question