Solved

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

Posted on 2013-06-10
3
239 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)
Comment Utility
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
Comment Utility
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
 

Author Closing Comment

by:dma70
Comment Utility
works great - thank you
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This is a little timesaver I have been using for setting up Microsoft Small Business Server (SBS) in the simplest possible way. It may not be appropriate for every customer. However, when you get a situation where the person who owns the server is i…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now