Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel 4

Status
Not open for further replies.

drfads07

Computer
Jun 24, 2009
6
Is there a way where you could display both the formula and its out put in the same cell.

For instance:

I am using a "substitution" formula which removes dashes from numbers- I want the output of that formula to be displayed in the same cell.

OR:

If there is a way excel can automatically format a cell when i paste something into it. Please help..


Regards
 
Replies continue below

Recommended for you

I did try it bit seems like I am not doing it rite, will post comments after further testing.

Going back I really think I need some kinda invoke script like
when Selection.paste in a range automatically run macro. See if you can point me into a direction. Thanks
 
I haven't found anything in excel that captures paste events. In the user forms, there is a BeforeDropOrPaste but I am not sure that would work for you.

An alternate solution would be to replace ctrl-V with a macro.

Save this macro in the module1 section of the VBA editor. Then in excel, on the macro dialog box there is an options button that allows you to assign keys to the macro.

Code:
Sub RemoveDashes()
Dim X As Variant
Dim mycell As Range
ActiveSheet.Paste
For Each mycell In Selection
    X = mycell.Value
    X = Replace(X, "-", "", 1)
    'The next line puts the cleaned up data back in mycell
    mycell.Value = X
Next mycell
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor