PC Review


Reply
Thread Tools Rate Thread

Copy a formula formatted as Text In Excel

 
 
Tim879
Guest
Posts: n/a
 
      6th Sep 2007
I have a UDF that returns the formula of a given cell in a text
format. Is there anyway to have excel recognize that the result of
the function is a formula and not text.

Once I click on the cell, hit F2 to edit it and then enter, Excel
realizes it's a formula and then calculates the value,

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      6th Sep 2007
Nope.

The formula in the cell is going to be the UDF--not the what formula string
looks like.

You could add some more steps.
Select the range (if more than one cell)
Convert to values (edit|copy, edit|paste special|values)
and finally
edit|replace
what: = (equal sign)
with: =
replace all

And excel will see them as formulas.

But I'm not sure why that would be better than just using a simple formula that
returns the value of the cell with the original formula.

Tim879 wrote:
>
> I have a UDF that returns the formula of a given cell in a text
> format. Is there anyway to have excel recognize that the result of
> the function is a formula and not text.
>
> Once I click on the cell, hit F2 to edit it and then enter, Excel
> realizes it's a formula and then calculates the value,


--

Dave Peterson
 
Reply With Quote
 
Tim879
Guest
Posts: n/a
 
      6th Sep 2007
I just figured I'd post my solution (and a better description of my
problem) in case anyone was interested.

I am doing a monthly reconciliation whereby I add up multiple values
in 2 columns (debits and credits) in a separate spreadsheet. For
example, cell a2 (the debits) would equal "=123+345" and b2 (the
credits) would equal "=567+789" when I'm done with the rec. Once I
verify that the rec. works, I then go back to my rec and copy the
values of a2 and b2 into 1 formula on my reconciliation. so the
corresponding cell on my rec would equal =(123+345)-(567+789). I know
there are better ways to do this but most would require me re-writing
the spreadsheet and since there are other people that use this file -
this appears to be the path of least resistance.

Either way... .here's my solution:
Sub CombineFormulas()
'Application.ScreenUpdating = False

If Selection.Columns.Count <> 1 Then
MsgBox "Macro only works if you select 1 column. Please select
1 column and re-run macro", vbCritical
Exit Sub
End If

For Each Cell In Selection
Formula1 =
WorksheetFunction.Substitute(WorksheetFunction.Substitute(Cell.Formula,
"'", ""), "=", "")
Formula2 =
WorksheetFunction.Substitute(WorksheetFunction.Substitute(Cell.Offset(0,
1).Formula, "'", ""), "=", "")

Cell2 = Cell.Offset(0, 2).Select

ActiveCell.FormulaR1C1 = "=(" & Formula1 & ")-(" & Formula2 &
")"

Next

End Sub

On Sep 6, 1:32 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> Nope.
>
> The formula in the cell is going to be the UDF--not the what formula string
> looks like.
>
> You could add some more steps.
> Select the range (if more than one cell)
> Convert to values (edit|copy, edit|paste special|values)
> and finally
> edit|replace
> what: = (equal sign)
> with: =
> replace all
>
> And excel will see them as formulas.
>
> But I'm not sure why that would be better than just using a simple formula that
> returns the value of the cell with the original formula.
>
> Tim879 wrote:
>
> > I have a UDF that returns the formula of a given cell in a text
> > format. Is there anyway to have excel recognize that the result of
> > the function is a formula and not text.

>
> > Once I click on the cell, hit F2 to edit it and then enter, Excel
> > realizes it's a formula and then calculates the value,

>
> --
>
> Dave Peterson



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy formatted text but not headers/footers Jamie Collins Microsoft Word Document Management 1 28th Apr 2010 09:31 AM
Formula in text formatted cell dworst@gaic.com Microsoft Excel Programming 3 27th Dec 2006 10:41 PM
How do I copy text using a formula between worksheets in Excel? =?Utf-8?B?R3Vlcm8=?= Microsoft Excel Worksheet Functions 2 23rd Mar 2006 06:31 PM
How do I create a formula in excel to automatically copy text fro. =?Utf-8?B?aWpnb2xkaW5n?= Microsoft Excel Misc 1 31st Jan 2005 12:37 PM
How can I copy formatted text from an Excel textbox into an IE .htm document ? Charles Jordan Microsoft Excel Programming 5 1st Dec 2003 02:18 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:18 AM.