Solved

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

Posted on 2013-06-10
3
250 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
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…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

914 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

14 Experts available now in Live!

Get 1:1 Help Now