Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
copy and paste an excel formula | New Users to Excel | |||
can't copy/paste the formula | Excel Discussion (Misc queries) | |||
Copy and Paste help needed - tia! | Excel Worksheet Functions | |||
Copy/Paste how to avoid the copy of formula cells w/o calc values | Excel Discussion (Misc queries) | |||
Why won't Excel let me copy and paste my concantenate formula now | Excel Worksheet Functions |