Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default Excel formula to copy/paste formula needed please.

I use excel 2007 and have a spreadsheet which has 350,000 rows of
data.

The data consists of many ranges.

Each range has a cell containing a formula. These cells are in the
same column but refer to different cells on another sheet.

I want to put the formula on the row above each range.

If I copy/paste I just get the result of the formula. Is it possible
to to have a formula which copy/pastes another formula???
Big thanks.
Colwyn.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,805
Default Excel formula to copy/paste formula needed please.

If you don't have formulae in two consecutive rows then the macro given below
will copy the formula, as text, in the cell above the cell containing the
formula.
Needs to be run only once... Make a copy of your spreadsheet before testing...
To enter the macro
-------------
1. Open the Visual Basic Editor by going to tools-Macro's-Visual Basic
Editor or use Alt-F11
2. On the toolbar of the Visual Basic Editor, go to insert - module after
selecting the workbook on the left in which you want to use this code
3. In the module pane paste the code below.
4. Close the Visual Basic Editor By clicking the X in the upper right
corner or go to File-Close
-------------
'-------------
'Code to copy. copy upto End Sub...
Sub copyFormulaString()
Dim LastRow
LastRow = Sheets("Sheet3").Cells(1048576, "A").End(xlUp).Row
Range("A" & LastRow).Select
Do Until ActiveCell.Row = 1
If Left(ActiveCell.Formula, 1) = "=" Then
ActiveCell.Offset(-1, 0).Value = "'" & ActiveCell.Formula
If ActiveCell.Row 2 Then
ActiveCell.Offset(-1, 0).Select
End If
End If
ActiveCell.Offset(-1, 0).Select
Loop
End Sub
'-------------

"colwyn" wrote:

I use excel 2007 and have a spreadsheet which has 350,000 rows of
data.

The data consists of many ranges.

Each range has a cell containing a formula. These cells are in the
same column but refer to different cells on another sheet.

I want to put the formula on the row above each range.

If I copy/paste I just get the result of the formula. Is it possible
to to have a formula which copy/pastes another formula???
Big thanks.
Colwyn.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default Excel formula to copy/paste formula needed please.

Sheeloo, excellent answer. I asked on several boards but yours was the
only one to do what was wanted.
Just one slight problem. The formula was being COPIED and pasted (my
fault!) when what I wanted it to do was CUT and paste. Now I have the
formula in two cells the original and the new one copied by your
formula in the cell above. Any idea as to how I can do this ??

I should add that I changed the code in order to show the result of
the formula rather than the text of same. That is, where your code
says
ActiveCell.Offset(-1, 0).Value = "'" & ActiveCell.Formula
I have deleted the ' between the " " as this now produces the formula
result.

Thank you for your help'
Colwyn.


On Oct 21, 7:17*pm, Sheeloo <="to" & CHAR(95) & "sheeloo" & CHAR(64) &
"hotmail.com" wrote:
If you don't have formulae in two consecutive rows then the macro given below
will copy the formula, as text, in the cell above the cell containing the
formula.
Needs to be run only once... Make a copy of your spreadsheet before testing...
To enter the macro
-------------
1. Open the Visual Basic Editor by going to tools-Macro's-Visual Basic
Editor or use Alt-F11
* *2. On the toolbar of the Visual Basic Editor, go to insert - module after
selecting the workbook on the left in which you want to use this code
* *3. In the module pane paste the code below.
* *4. Close the Visual Basic Editor By clicking the X in the upper right
corner or go to File-Close
-------------
'-------------
'Code to copy. copy upto End Sub...
Sub copyFormulaString()
Dim LastRow
LastRow = Sheets("Sheet3").Cells(1048576, "A").End(xlUp).Row
Range("A" & LastRow).Select
Do Until ActiveCell.Row = 1
* * If Left(ActiveCell.Formula, 1) = "=" Then
* * *ActiveCell.Offset(-1, 0).Value = "'" & ActiveCell.Formula
* * *If ActiveCell.Row 2 Then
* * * ActiveCell.Offset(-1, 0).Select
* * *End If
* * End If
*ActiveCell.Offset(-1, 0).Select
Loop
End Sub
'-------------

"colwyn" wrote:
I use excel 2007 and *have a spreadsheet which has 350,000 rows of
data.


The data consists of many ranges.


Each range has a cell containing a formula. These cells are in the
same column but refer to different cells on another sheet.


I want to put the formula on the row above each range.


If I copy/paste I just get the result of the formula. Is it possible
to to have a formula which copy/pastes another formula???
Big thanks.
Colwyn.


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,805
Default Excel formula to copy/paste formula needed please.


Glad I could help.

Just add the line
ActiveCell.Value=""
after the changde line
ActiveCell.Offset(-1, 0).Value = "'" & ActiveCell.Formula
"colwyn" wrote:

Sheeloo, excellent answer. I asked on several boards but yours was the
only one to do what was wanted.
Just one slight problem. The formula was being COPIED and pasted (my
fault!) when what I wanted it to do was CUT and paste. Now I have the
formula in two cells the original and the new one copied by your
formula in the cell above. Any idea as to how I can do this ??

I should add that I changed the code in order to show the result of
the formula rather than the text of same. That is, where your code
says
ActiveCell.Offset(-1, 0).Value = "'" & ActiveCell.Formula
I have deleted the ' between the " " as this now produces the formula
result.

Thank you for your help'
Colwyn.


On Oct 21, 7:17 pm, Sheeloo <="to" & CHAR(95) & "sheeloo" & CHAR(64) &
"hotmail.com" wrote:
If you don't have formulae in two consecutive rows then the macro given below
will copy the formula, as text, in the cell above the cell containing the
formula.
Needs to be run only once... Make a copy of your spreadsheet before testing...
To enter the macro
-------------
1. Open the Visual Basic Editor by going to tools-Macro's-Visual Basic
Editor or use Alt-F11
2. On the toolbar of the Visual Basic Editor, go to insert - module after
selecting the workbook on the left in which you want to use this code
3. In the module pane paste the code below.
4. Close the Visual Basic Editor By clicking the X in the upper right
corner or go to File-Close
-------------
'-------------
'Code to copy. copy upto End Sub...
Sub copyFormulaString()
Dim LastRow
LastRow = Sheets("Sheet3").Cells(1048576, "A").End(xlUp).Row
Range("A" & LastRow).Select
Do Until ActiveCell.Row = 1
If Left(ActiveCell.Formula, 1) = "=" Then
ActiveCell.Offset(-1, 0).Value = "'" & ActiveCell.Formula
If ActiveCell.Row 2 Then
ActiveCell.Offset(-1, 0).Select
End If
End If
ActiveCell.Offset(-1, 0).Select
Loop
End Sub
'-------------

"colwyn" wrote:
I use excel 2007 and have a spreadsheet which has 350,000 rows of
data.


The data consists of many ranges.


Each range has a cell containing a formula. These cells are in the
same column but refer to different cells on another sheet.


I want to put the formula on the row above each range.


If I copy/paste I just get the result of the formula. Is it possible
to to have a formula which copy/pastes another formula???
Big thanks.
Colwyn.



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default Excel formula to copy/paste formula needed please.

Big Thanks Sheeloo. That works perfectly
Thanks again.
Colwyn.




On Oct 22, 6:05*pm, Sheeloo <="to" & CHAR(95) & "sheeloo" & CHAR(64) &
"hotmail.com" wrote:
Glad I could help.

Just add the line
ActiveCell.Value=""
after the changde line
ActiveCell.Offset(-1, 0).Value = "'" & ActiveCell.Formula

"colwyn" wrote:
Sheeloo, excellent answer. I asked on several boards but yours was the
only one to do what was wanted.
Just one slight problem. The formula was being COPIED and pasted (my
fault!) when what I wanted it to do was CUT and paste. Now I have the
formula in two cells the original and the new one copied by your
formula in the cell above. Any idea as to how I can do this ??


I should add that I changed the code in order to show the result of
the formula rather than the text of same. That is, where your code
says
ActiveCell.Offset(-1, 0).Value = "'" & ActiveCell.Formula
I have deleted the ' between the " " as this now produces the formula
result.


Thank you for your help'
Colwyn.


On Oct 21, 7:17 pm, Sheeloo <="to" & CHAR(95) & "sheeloo" & CHAR(64) &
"hotmail.com" wrote:
If you don't have formulae in two consecutive rows then the macro given below
will copy the formula, as text, in the cell above the cell containing the
formula.
Needs to be run only once... Make a copy of your spreadsheet before testing...
To enter the macro
-------------
1. Open the Visual Basic Editor by going to tools-Macro's-Visual Basic
Editor or use Alt-F11
* *2. On the toolbar of the Visual Basic Editor, go to insert - module after
selecting the workbook on the left in which you want to use this code
* *3. In the module pane paste the code below.
* *4. Close the Visual Basic Editor By clicking the X in the upper right
corner or go to File-Close
-------------
'-------------
'Code to copy. copy upto End Sub...
Sub copyFormulaString()
Dim LastRow
LastRow = Sheets("Sheet3").Cells(1048576, "A").End(xlUp).Row
Range("A" & LastRow).Select
Do Until ActiveCell.Row = 1
* * If Left(ActiveCell.Formula, 1) = "=" Then
* * *ActiveCell.Offset(-1, 0).Value = "'" & ActiveCell.Formula
* * *If ActiveCell.Row 2 Then
* * * ActiveCell.Offset(-1, 0).Select
* * *End If
* * End If
*ActiveCell.Offset(-1, 0).Select
Loop
End Sub
'-------------


"colwyn" wrote:
I use excel 2007 and *have a spreadsheet which has 350,000 rows of
data.


The data consists of many ranges.


Each range has a cell containing a formula. These cells are in the
same column but refer to different cells on another sheet.


I want to put the formula on the row above each range.


If I copy/paste I just get the result of the formula. Is it possible
to to have a formula which copy/pastes another formula???
Big thanks.
Colwyn.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy and paste an excel formula Cannot copy and paste an excel formula New Users to Excel 2 June 14th 08 05:50 PM
can't copy/paste the formula Janis Excel Discussion (Misc queries) 2 August 14th 07 07:38 PM
Copy and Paste help needed - tia! masterdiablo13 Excel Worksheet Functions 2 September 27th 06 03:12 AM
Copy/Paste how to avoid the copy of formula cells w/o calc values Dennis Excel Discussion (Misc queries) 10 March 2nd 06 11:47 PM
Why won't Excel let me copy and paste my concantenate formula now Jennifer Excel Worksheet Functions 3 February 6th 06 05:14 PM


All times are GMT +1. The time now is 08:34 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"