Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-06-10
3
Medium Priority
?
291 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 1600 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

963 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