You know - just the expression.
For example things like "=1+A1" or "=A1*B1"
Right now it changes the cells even with Paste Special!
You know - just the expression.
For example things like "=1+A1" or "=A1*B1"
Right now it changes the cells even with Paste Special!
Last edited by martix; 05-13-2009 at 08:38 PM.
See Help for About cell and range references
Entia non sunt multiplicanda sine necessitate
But how do I do it en masse? Without changing any of the references anyhow...
Here is what I figured just now - select what is to be copied; Replace [=] with ['=]; do the copy; replace back.
Do you mean to tell me that there is no other way to get the same results without all those steps?
If you use absolute references, they won't change.
Well I'd have to edit an already large enough dataset. Sure Excel has some form of regexes, but they are very awkward to deal with.
And still I end up with the replace function. :P
So can I assume that the answer to my previous question is - Yes, there is no straightforward way.![]()
I have a function that does it for a single cell -- I use it when I want to try variations of formulas, and want to make sure that the variation gives the same result.
The reason that Excel doesn't have any method (that I know of) is that people rarely want to see the same thing calculated with the same values in more than one place. Why do you?
You could use a a sub:
Then from the Immediate window, for example,![]()
Sub FormulaCopy(rInp As Range, rOut As Range) ' Copies formula in rInp to rOut without adjustments to references rOut.Resize(rInp.Rows.Count, rInp.Columns.Count).Value = rInp.Formula End Sub
![]()
FormulaCopy range("B1:B10"), range("D3")
For the exact same reason as you...For example I want to see if a pattern is preserved on other arguments/constants or the relation between the two sets of data.
Only that I use array formulas quite often.
Here are the functions I use to copy a single formula:
You need a set a reference to Microsoft Forms Object Library.![]()
Sub CopyFormula() ' shortcut Ctrl+Shift+C Dim oDO As DataObject Set oDO = New DataObject oDO.SetText ActiveCell.Formula oDO.PutInClipboard End Sub Sub PasteFormula() ' shortcut Ctrl+Shift+V Dim oDO As DataObject Dim cell As Range If TypeName(Selection) <> "Range" Then MsgBox "Selection must be a Range!", "PasteFormula" Exit Sub End If Set oDO = New DataObject On Error Resume Next oDO.GetFromClipboard For Each cell In Selection cell.Formula = oDO.GetText Next cell End Sub
If you're copying array formulas, you have to remake them as array formulas -- I never had occasion to need to do so, so the code doesn't.
Last edited by shg; 05-13-2009 at 08:13 PM.
I see... well thanks![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks