PC Review


Reply
Thread Tools Rate Thread

Copy Formula without changing cell refence

 
 
Agustus
Guest
Posts: n/a
 
      18th Jan 2007
Hi,

I modified this macro from earlier post fom Tom Ogilvy, but it is doing
exactly what it should be. I like to copy the formula in a selected
cell(s) and paste them in another cell without changing the cell
reference. Can someone help, please?

Thank you in advance.

Agustus

Sub CopyFormulas1()
Dim rng1 As Range, rng2 As Range, i As Long
On Error Resume Next
Set rng1 = Selection.CurrentRegion
' original post had this: Set rng1 = Application.InputBox("Select cells
to copy using mouse", Type:=8)
On Error GoTo 0
If rng1 Is Nothing Then
MsgBox "You selected nothing"
Exit Sub
End If

On Error Resume Next
Set rng2 = Application.InputBox("Select top cell to paste using mouse",
_
Type:=8)
On Error GoTo 0
If rng2 Is Nothing Then
MsgBox "You selected nothing"
Exit Sub
End If

i = 1
For Each cell In rng1
rng2(i).Formula = cell.Formula
i = i + 1
Next

End Sub

 
Reply With Quote
 
 
 
 
Agustus
Guest
Posts: n/a
 
      18th Jan 2007
Sorry, typo..

I modified this macro from earlier post fom Tom Ogilvy, but it is Not
doing
exactly what it should be. I like to copy the formula in a selected
cell(s) and paste them in another cell without changing the cell
reference. Can someone help, please?


> Hi,
>
> I modified this macro from earlier post fom Tom Ogilvy, but it is doing
> exactly what it should be. I like to copy the formula in a selected
> cell(s) and paste them in another cell without changing the cell
> reference. Can someone help, please?
>
> Thank you in advance.
>
> Agustus
>
> Sub CopyFormulas1()
> Dim rng1 As Range, rng2 As Range, i As Long
> On Error Resume Next
> Set rng1 = Selection.CurrentRegion
> ' original post had this: Set rng1 = Application.InputBox("Select cells
> to copy using mouse", Type:=8)
> On Error GoTo 0
> If rng1 Is Nothing Then
> MsgBox "You selected nothing"
> Exit Sub
> End If
>
> On Error Resume Next
> Set rng2 = Application.InputBox("Select top cell to paste using mouse",
> _
> Type:=8)
> On Error GoTo 0
> If rng2 Is Nothing Then
> MsgBox "You selected nothing"
> Exit Sub
> End If
>
> i = 1
> For Each cell In rng1
> rng2(i).Formula = cell.Formula
> i = i + 1
> Next
>
> End Sub


 
Reply With Quote
 
Agustus
Guest
Posts: n/a
 
      19th Jan 2007
Gary''s Student,
Thank you for your reply. Even though it is not what I had intended in
mind as the destination range needed to be dynamic, but you've given me
ideas for the next steps.

Regards,
Agustus

Gary''s Student wrote:
> Just avoid Copy/Paste:
>
> Sub augi()
> Range("Z100").Formula = Range("C10").Formula
> End Sub
>
> will take the formula in C10 and "copy" it to Z100. No cell references will
> change.
> --
> Gary's Student
> gsnu200701
>
>
> "Agustus" wrote:
>
> > Sorry, typo..
> >
> > I modified this macro from earlier post fom Tom Ogilvy, but it is Not
> > doing
> > exactly what it should be. I like to copy the formula in a selected
> > cell(s) and paste them in another cell without changing the cell
> > reference. Can someone help, please?
> >
> >
> > > Hi,
> > >
> > > I modified this macro from earlier post fom Tom Ogilvy, but it is doing
> > > exactly what it should be. I like to copy the formula in a selected
> > > cell(s) and paste them in another cell without changing the cell
> > > reference. Can someone help, please?
> > >
> > > Thank you in advance.
> > >
> > > Agustus
> > >
> > > Sub CopyFormulas1()
> > > Dim rng1 As Range, rng2 As Range, i As Long
> > > On Error Resume Next
> > > Set rng1 = Selection.CurrentRegion
> > > ' original post had this: Set rng1 = Application.InputBox("Select cells
> > > to copy using mouse", Type:=8)
> > > On Error GoTo 0
> > > If rng1 Is Nothing Then
> > > MsgBox "You selected nothing"
> > > Exit Sub
> > > End If
> > >
> > > On Error Resume Next
> > > Set rng2 = Application.InputBox("Select top cell to paste using mouse",
> > > _
> > > Type:=8)
> > > On Error GoTo 0
> > > If rng2 Is Nothing Then
> > > MsgBox "You selected nothing"
> > > Exit Sub
> > > End If
> > >
> > > i = 1
> > > For Each cell In rng1
> > > rng2(i).Formula = cell.Formula
> > > i = i + 1
> > > Next
> > >
> > > End Sub

> >
> >


 
Reply With Quote
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      19th Jan 2007
Update this post if you require anthing else.
--
Gary''s Student
gsnu200702


"Agustus" wrote:

> Gary''s Student,
> Thank you for your reply. Even though it is not what I had intended in
> mind as the destination range needed to be dynamic, but you've given me
> ideas for the next steps.
>
> Regards,
> Agustus
>
> Gary''s Student wrote:
> > Just avoid Copy/Paste:
> >
> > Sub augi()
> > Range("Z100").Formula = Range("C10").Formula
> > End Sub
> >
> > will take the formula in C10 and "copy" it to Z100. No cell references will
> > change.
> > --
> > Gary's Student
> > gsnu200701
> >
> >
> > "Agustus" wrote:
> >
> > > Sorry, typo..
> > >
> > > I modified this macro from earlier post fom Tom Ogilvy, but it is Not
> > > doing
> > > exactly what it should be. I like to copy the formula in a selected
> > > cell(s) and paste them in another cell without changing the cell
> > > reference. Can someone help, please?
> > >
> > >
> > > > Hi,
> > > >
> > > > I modified this macro from earlier post fom Tom Ogilvy, but it is doing
> > > > exactly what it should be. I like to copy the formula in a selected
> > > > cell(s) and paste them in another cell without changing the cell
> > > > reference. Can someone help, please?
> > > >
> > > > Thank you in advance.
> > > >
> > > > Agustus
> > > >
> > > > Sub CopyFormulas1()
> > > > Dim rng1 As Range, rng2 As Range, i As Long
> > > > On Error Resume Next
> > > > Set rng1 = Selection.CurrentRegion
> > > > ' original post had this: Set rng1 = Application.InputBox("Select cells
> > > > to copy using mouse", Type:=8)
> > > > On Error GoTo 0
> > > > If rng1 Is Nothing Then
> > > > MsgBox "You selected nothing"
> > > > Exit Sub
> > > > End If
> > > >
> > > > On Error Resume Next
> > > > Set rng2 = Application.InputBox("Select top cell to paste using mouse",
> > > > _
> > > > Type:=8)
> > > > On Error GoTo 0
> > > > If rng2 Is Nothing Then
> > > > MsgBox "You selected nothing"
> > > > Exit Sub
> > > > End If
> > > >
> > > > i = 1
> > > > For Each cell In rng1
> > > > rng2(i).Formula = cell.Formula
> > > > i = i + 1
> > > > Next
> > > >
> > > > End Sub
> > >
> > >

>
>

 
Reply With Quote
 
cathellisuk@yahoo.co.uk
Guest
Posts: n/a
 
      20th Jan 2007
Agustus's copy problem interested me as it's something I need to do
myself on occasion. I have been exploring a few ways to copy formulae
without changing the cell references using the keyboard (or mouse if
you prefer).
I know this is an Excel programming group but sometimes the good old
keyboard can be useful.
I'm using Excel version 2002.

Here are a couple of solutions someone might find useful.


1. Copying formulae from a range of contiguous cells. (eg D5 to
G10) without changing the cell references in the formulae.

a) open up a text editor ( Notepad , Word . . .whatever you like)
b) In Excel change the view option on the worksheet to show cell
formula rather than values.
The quickest way to do this is to press Ctrl + ` (that's a
single left quotation mark)
This key combination toggles the display between value and
formula view.

c) Select the cells you want to copy the formulae from
d) Press Ctrl+C (to copy to the clipboard)
e) Swap to your text editor
f) Press Ctrl + V to paste the formulae.
g) In the text editor select the text you have just pasted
h) Press Ctrl + C to copy it
i) Back in Excel select the top left hand cell of the range you want to
paste into
j) Press Ctrl + V to paste the formulae
h) Press Ctrl + ` again to put Excel back in view "values" mode. This
step can be done after step (d) if you prefer.

I was surprised at how well this copy method works. Even if the source
range you have copied contains a number of blanks cells Excel still
pastes the text in the clipboard into the right target cells.

2. Copying a formula from a "single" cell without altering the formula

The trick here is to copy the formula FROM THE FORMULA BAR rather than
from the source cell. This can be done by :
a) select the cell you want to copy
b) In the formula bar select all text that makes up the formula
c) Press Ctrl + C to copy to the clipboard
d) select the cell you want to paste into
e) Press Ctrl + V to paste the formula

Cath

 
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 an exact formula without changing cell reference Vidal Microsoft Excel Worksheet Functions 1 5th Sep 2009 09:48 AM
refence worksheet name into a formula excelhurtsme Microsoft Excel Misc 5 20th Oct 2008 04:46 PM
Way To Copy Formula In Column Without Changing All Cell Numbers travelersway Microsoft Excel Misc 2 3rd Sep 2005 08:36 PM
HOW DO I COPY FORMULA WITHOUT CHANGING CELL REFERENCE =?Utf-8?B?YW5hbnR0aA==?= Microsoft Excel Misc 4 6th Feb 2005 12:25 PM
Refence Worksheet Tab Name in Cell Stefan Microsoft Excel Worksheet Functions 2 2nd Sep 2004 02:34 PM


Features
 

Advertising
 

Newsgroups
 


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