Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello all,
First off, let me just say that I am a non-programmer and do not know anything about VB, but am hoping that someone here can help me out. I have a formula in cell A75 and the cell references in the formula have to be changed once a month, thus I would like to have a macro I can run each time the cell references need to be changed. An example of the formula is as follows: Formula = SUM(D3,E4,F5)/SUM(C3,D4,E5) Upon running the macro, the formula would change as follows: Formula = SUM(E4,F5,G6)/SUM(D4,E5,F6) and running the macro again, the formula would change to: Formula = SUM(F5,G6,H7)/SUM(E5,F6,G7) Much thanks in advance to anyone who can provide me with a solution to this. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How close to reality is that "example" formula? What you are asking could be
difficult to implement if you are looking for a generalized solution as opposed to a solution for a given set formula (I'm thinking of situations with single cell versus multiple cell references at the moment). Also, is the progression you showed (each reference has its row and column incremented by one) exactly what you want to have done? -- Rick (MVP - Excel) "510 Financeguy" wrote in message ... Hello all, First off, let me just say that I am a non-programmer and do not know anything about VB, but am hoping that someone here can help me out. I have a formula in cell A75 and the cell references in the formula have to be changed once a month, thus I would like to have a macro I can run each time the cell references need to be changed. An example of the formula is as follows: Formula = SUM(D3,E4,F5)/SUM(C3,D4,E5) Upon running the macro, the formula would change as follows: Formula = SUM(E4,F5,G6)/SUM(D4,E5,F6) and running the macro again, the formula would change to: Formula = SUM(F5,G6,H7)/SUM(E5,F6,G7) Much thanks in advance to anyone who can provide me with a solution to this. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The "example" formula is the exact formula I am using, as is the progression
(in which each cell reference has its row and column incremented by one). "Rick Rothstein" wrote: How close to reality is that "example" formula? What you are asking could be difficult to implement if you are looking for a generalized solution as opposed to a solution for a given set formula (I'm thinking of situations with single cell versus multiple cell references at the moment). Also, is the progression you showed (each reference has its row and column incremented by one) exactly what you want to have done? -- Rick (MVP - Excel) "510 Financeguy" wrote in message ... Hello all, First off, let me just say that I am a non-programmer and do not know anything about VB, but am hoping that someone here can help me out. I have a formula in cell A75 and the cell references in the formula have to be changed once a month, thus I would like to have a macro I can run each time the cell references need to be changed. An example of the formula is as follows: Formula = SUM(D3,E4,F5)/SUM(C3,D4,E5) Upon running the macro, the formula would change as follows: Formula = SUM(E4,F5,G6)/SUM(D4,E5,F6) and running the macro again, the formula would change to: Formula = SUM(F5,G6,H7)/SUM(E5,F6,G7) Much thanks in advance to anyone who can provide me with a solution to this. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I'm sure I've made hard work of this and someone is going to post an elegant solution but this works. If B76 and B77 are empty then the first and last 2 lines aren't necessary. Sub IncrementIt() myb76 = Range("B76").Formula myb77 = Range("B77").Formula Range("A76").AutoFill Destination:=Range("A76:B76") Range("B76").AutoFill Destination:=Range("B76:B77") Range("A76") = "'" & Range("B77").Formula Range("A76").Formula = Range("A76").Formula Range("B76").Formula = myb76 Range("B77").Formula = myb77 End Sub Mike "510 Financeguy" wrote: The "example" formula is the exact formula I am using, as is the progression (in which each cell reference has its row and column incremented by one). "Rick Rothstein" wrote: How close to reality is that "example" formula? What you are asking could be difficult to implement if you are looking for a generalized solution as opposed to a solution for a given set formula (I'm thinking of situations with single cell versus multiple cell references at the moment). Also, is the progression you showed (each reference has its row and column incremented by one) exactly what you want to have done? -- Rick (MVP - Excel) "510 Financeguy" wrote in message ... Hello all, First off, let me just say that I am a non-programmer and do not know anything about VB, but am hoping that someone here can help me out. I have a formula in cell A75 and the cell references in the formula have to be changed once a month, thus I would like to have a macro I can run each time the cell references need to be changed. An example of the formula is as follows: Formula = SUM(D3,E4,F5)/SUM(C3,D4,E5) Upon running the macro, the formula would change as follows: Formula = SUM(E4,F5,G6)/SUM(D4,E5,F6) and running the macro again, the formula would change to: Formula = SUM(F5,G6,H7)/SUM(E5,F6,G7) Much thanks in advance to anyone who can provide me with a solution to this. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Give this macro a try (change the worksheet name assigned to the SheetName
constant to the name of your actual worksheet)... Sub IncreaseReferences() Dim F As String Dim OldCells1 As String Dim OldCells2 As String Dim NewCells1 As String Dim NewCells2 As String Dim Parts() As String Const SheetName As String = "Sheet1" F = Worksheets(SheetName).Range("A75").Formula Parts = Split(F, "(") OldCells1 = Split(Parts(1), ")")(0) OldCells2 = Split(Parts(2), ")")(0) NewCells1 = Range(OldCells1).Offset(1, 1).Address(0, 0) NewCells2 = Range(OldCells2).Offset(1, 1).Address(0, 0) Worksheets(SheetName).Range("A75").Formula = Replace(Replace( _ F, OldCells1, NewCells1, , 1), OldCells2, NewCells2) End Sub -- Rick (MVP - Excel) "510 Financeguy" wrote in message ... The "example" formula is the exact formula I am using, as is the progression (in which each cell reference has its row and column incremented by one). "Rick Rothstein" wrote: How close to reality is that "example" formula? What you are asking could be difficult to implement if you are looking for a generalized solution as opposed to a solution for a given set formula (I'm thinking of situations with single cell versus multiple cell references at the moment). Also, is the progression you showed (each reference has its row and column incremented by one) exactly what you want to have done? -- Rick (MVP - Excel) "510 Financeguy" wrote in message ... Hello all, First off, let me just say that I am a non-programmer and do not know anything about VB, but am hoping that someone here can help me out. I have a formula in cell A75 and the cell references in the formula have to be changed once a month, thus I would like to have a macro I can run each time the cell references need to be changed. An example of the formula is as follows: Formula = SUM(D3,E4,F5)/SUM(C3,D4,E5) Upon running the macro, the formula would change as follows: Formula = SUM(E4,F5,G6)/SUM(D4,E5,F6) and running the macro again, the formula would change to: Formula = SUM(F5,G6,H7)/SUM(E5,F6,G7) Much thanks in advance to anyone who can provide me with a solution to this. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Rick,
This worked perfectly. Thank you again for your assistance. "Rick Rothstein" wrote: Give this macro a try (change the worksheet name assigned to the SheetName constant to the name of your actual worksheet)... Sub IncreaseReferences() Dim F As String Dim OldCells1 As String Dim OldCells2 As String Dim NewCells1 As String Dim NewCells2 As String Dim Parts() As String Const SheetName As String = "Sheet1" F = Worksheets(SheetName).Range("A75").Formula Parts = Split(F, "(") OldCells1 = Split(Parts(1), ")")(0) OldCells2 = Split(Parts(2), ")")(0) NewCells1 = Range(OldCells1).Offset(1, 1).Address(0, 0) NewCells2 = Range(OldCells2).Offset(1, 1).Address(0, 0) Worksheets(SheetName).Range("A75").Formula = Replace(Replace( _ F, OldCells1, NewCells1, , 1), OldCells2, NewCells2) End Sub -- Rick (MVP - Excel) "510 Financeguy" wrote in message ... The "example" formula is the exact formula I am using, as is the progression (in which each cell reference has its row and column incremented by one). "Rick Rothstein" wrote: How close to reality is that "example" formula? What you are asking could be difficult to implement if you are looking for a generalized solution as opposed to a solution for a given set formula (I'm thinking of situations with single cell versus multiple cell references at the moment). Also, is the progression you showed (each reference has its row and column incremented by one) exactly what you want to have done? -- Rick (MVP - Excel) "510 Financeguy" wrote in message ... Hello all, First off, let me just say that I am a non-programmer and do not know anything about VB, but am hoping that someone here can help me out. I have a formula in cell A75 and the cell references in the formula have to be changed once a month, thus I would like to have a macro I can run each time the cell references need to be changed. An example of the formula is as follows: Formula = SUM(D3,E4,F5)/SUM(C3,D4,E5) Upon running the macro, the formula would change as follows: Formula = SUM(E4,F5,G6)/SUM(D4,E5,F6) and running the macro again, the formula would change to: Formula = SUM(F5,G6,H7)/SUM(E5,F6,G7) Much thanks in advance to anyone who can provide me with a solution to this. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro recorded... tabs & file names changed, macro hangs | Excel Worksheet Functions | |||
AutoRun Macro with a delay to give user the choice to cancel the macro | Excel Programming | |||
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor | Excel Programming | |||
macro to delete entire rows when column A is blank ...a quick macro | Excel Programming | |||
Start Macro / Stop Macro / Restart Macro | Excel Programming |