#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro Help

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Macro Help

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro Help

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Macro Help

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Macro Help

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro Help

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
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
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
AutoRun Macro with a delay to give user the choice to cancel the macro wanderlust Excel Programming 2 September 28th 07 04:09 PM
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor [email protected] Excel Programming 2 March 30th 07 07:48 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


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

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

About Us

"It's about Microsoft Excel"