![]() |
Pasting formula with defined name
I want to paste a formula which has a defined name and does not exist in any cell on any worksheet before I paste it. I know that
defined name formulas can be referred to by other formulas on a worksheet, but I want to paste the defined name formulas programmatically. I know that there are other ways to accomplish what I'm doing in my project without using the named formulas, but using them would be a lot cleaner for me and I want to take advantage of that feature if possible. Any ideas? -- RMC,CPA |
Pasting formula with defined name
Hi
is this what you're after Sub pasteformula() Range("D1").Formula = "=SUM(myname)" End Sub Cheers JulieD "R. Choate" wrote in message ... I want to paste a formula which has a defined name and does not exist in any cell on any worksheet before I paste it. I know that defined name formulas can be referred to by other formulas on a worksheet, but I want to paste the defined name formulas programmatically. I know that there are other ways to accomplish what I'm doing in my project without using the named formulas, but using them would be a lot cleaner for me and I want to take advantage of that feature if possible. Any ideas? -- RMC,CPA |
Pasting formula with defined name
No, what I'm referring to is where the formula itself has a "range name" instead of the normal case where a range name refers to
cells on a worksheet. Lets say the formula is "=B1-B2" and the formula's name is "NetPounds". I want to paste my formula in various places and refer to it by its name, "NetPounds". To use your example, my code would look more like: Sub pasteformula() Range("D1").Formula = "NetPounds" End Sub Any ideas? Thanks! -- RMC,CPA "JulieD" wrote in message ... Hi is this what you're after Sub pasteformula() Range("D1").Formula = "=SUM(myname)" End Sub Cheers JulieD "R. Choate" wrote in message ... I want to paste a formula which has a defined name and does not exist in any cell on any worksheet before I paste it. I know that defined name formulas can be referred to by other formulas on a worksheet, but I want to paste the defined name formulas programmatically. I know that there are other ways to accomplish what I'm doing in my project without using the named formulas, but using them would be a lot cleaner for me and I want to take advantage of that feature if possible. Any ideas? -- RMC,CPA |
Pasting formula with defined name
Try:
Sub pasteformula() Range("D1").Formula = "=NetPounds" End Sub Be careful though because the range formula will be relative to the cell you were in when you created the Named Range Formula. For example, I tested your example in cell A1 with the formula =B1-B2. When I copied the formula to cell A6 it refers to =B6-B7. Regards Trevor "R. Choate" wrote in message ... No, what I'm referring to is where the formula itself has a "range name" instead of the normal case where a range name refers to cells on a worksheet. Lets say the formula is "=B1-B2" and the formula's name is "NetPounds". I want to paste my formula in various places and refer to it by its name, "NetPounds". To use your example, my code would look more like: Sub pasteformula() Range("D1").Formula = "NetPounds" End Sub Any ideas? Thanks! -- RMC,CPA "JulieD" wrote in message ... Hi is this what you're after Sub pasteformula() Range("D1").Formula = "=SUM(myname)" End Sub Cheers JulieD "R. Choate" wrote in message ... I want to paste a formula which has a defined name and does not exist in any cell on any worksheet before I paste it. I know that defined name formulas can be referred to by other formulas on a worksheet, but I want to paste the defined name formulas programmatically. I know that there are other ways to accomplish what I'm doing in my project without using the named formulas, but using them would be a lot cleaner for me and I want to take advantage of that feature if possible. Any ideas? -- RMC,CPA |
Pasting formula with defined name
That was it. I had left off the "=" at the beginning of the rangename. How stupid of me, but many thanks to you for putting me back
on track. With regard to the relative referencing, that is just perfect as it is because I need to copy it across. Thanks much. -- RMC,CPA "Trevor Shuttleworth" wrote in message ... Try: Sub pasteformula() Range("D1").Formula = "=NetPounds" End Sub Be careful though because the range formula will be relative to the cell you were in when you created the Named Range Formula. For example, I tested your example in cell A1 with the formula =B1-B2. When I copied the formula to cell A6 it refers to =B6-B7. Regards Trevor "R. Choate" wrote in message ... No, what I'm referring to is where the formula itself has a "range name" instead of the normal case where a range name refers to cells on a worksheet. Lets say the formula is "=B1-B2" and the formula's name is "NetPounds". I want to paste my formula in various places and refer to it by its name, "NetPounds". To use your example, my code would look more like: Sub pasteformula() Range("D1").Formula = "NetPounds" End Sub Any ideas? Thanks! -- RMC,CPA "JulieD" wrote in message ... Hi is this what you're after Sub pasteformula() Range("D1").Formula = "=SUM(myname)" End Sub Cheers JulieD "R. Choate" wrote in message ... I want to paste a formula which has a defined name and does not exist in any cell on any worksheet before I paste it. I know that defined name formulas can be referred to by other formulas on a worksheet, but I want to paste the defined name formulas programmatically. I know that there are other ways to accomplish what I'm doing in my project without using the named formulas, but using them would be a lot cleaner for me and I want to take advantage of that feature if possible. Any ideas? -- RMC,CPA |
All times are GMT +1. The time now is 07:30 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com