Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Macro for recurring formula; max of set of cells

Hello Group,

I am trying to automate this using a macro. I am trying to populate
the values of set of cells with a single click of a command button.
I tried FOR loop and all I get is just errors. Could someone please
help me to write a macro for the following:

Case 1:
'Max of interval 18
Formula in cell D1 =max(E2:E19)
Formula in cell D2 =max(E20:E37)
Formula in cell D3 =max(E38:E55)
......
Formula in cell D117......

Case2:
'Max of interval 18 - Mid value of interval 18
Formula in cell G1 =(max(F2:F19) - F10)
Formula in cell G2 =max(F20:F37) - F28)
Formula in cell G3 =max(F38:F55) - F46)
......
Formula in cell D117.....

Any help would be much appreciated.

Thanks,
Kevin
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Macro for recurring formula; max of set of cells

Try this,

Right click your sheet tab, view code and paste this in and run it. If you
want the step to be variable you could do that with an input box to get the
step value or read it from a worksheet cell.

Sub FillumUp()
myrow = 1
For X = 2 To 5000 Step 18
Range("D" & myrow).Formula = "=Max(E" & X & ":E" & X + 17 & ")"
Range("G" & myrow).Formula = "=Max(F" & X & ":g" & X + 17 & ")-F" & X + 8
myrow = myrow + 1
If myrow = 118 Then Exit Sub
Next
End Sub

Mike

" wrote:

Hello Group,

I am trying to automate this using a macro. I am trying to populate
the values of set of cells with a single click of a command button.
I tried FOR loop and all I get is just errors. Could someone please
help me to write a macro for the following:

Case 1:
'Max of interval 18
Formula in cell D1 =max(E2:E19)
Formula in cell D2 =max(E20:E37)
Formula in cell D3 =max(E38:E55)
......
Formula in cell D117......

Case2:
'Max of interval 18 - Mid value of interval 18
Formula in cell G1 =(max(F2:F19) - F10)
Formula in cell G2 =max(F20:F37) - F28)
Formula in cell G3 =max(F38:F55) - F46)
......
Formula in cell D117.....

Any help would be much appreciated.

Thanks,
Kevin

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Macro for recurring formula; max of set of cells

OOPS,

Typo. Try this instead

Sub FillumUp()
myrow = 1
For X = 2 To 5000 Step 18
Range("D" & myrow).Formula = "=Max(E" & X & ":E" & X + 17 & ")"
Range("G" & myrow).Formula = "=Max(F" & X & ":F" & X + 17 & ")-F" & X + 8
myrow = myrow + 1
If myrow = 118 Then Exit Sub
Next
End Sub

"Mike H" wrote:

Try this,

Right click your sheet tab, view code and paste this in and run it. If you
want the step to be variable you could do that with an input box to get the
step value or read it from a worksheet cell.

Sub FillumUp()
myrow = 1
For X = 2 To 5000 Step 18
Range("D" & myrow).Formula = "=Max(E" & X & ":E" & X + 17 & ")"
Range("G" & myrow).Formula = "=Max(F" & X & ":g" & X + 17 & ")-F" & X + 8
myrow = myrow + 1
If myrow = 118 Then Exit Sub
Next
End Sub

Mike

" wrote:

Hello Group,

I am trying to automate this using a macro. I am trying to populate
the values of set of cells with a single click of a command button.
I tried FOR loop and all I get is just errors. Could someone please
help me to write a macro for the following:

Case 1:
'Max of interval 18
Formula in cell D1 =max(E2:E19)
Formula in cell D2 =max(E20:E37)
Formula in cell D3 =max(E38:E55)
......
Formula in cell D117......

Case2:
'Max of interval 18 - Mid value of interval 18
Formula in cell G1 =(max(F2:F19) - F10)
Formula in cell G2 =max(F20:F37) - F28)
Formula in cell G3 =max(F38:F55) - F46)
......
Formula in cell D117.....

Any help would be much appreciated.

Thanks,
Kevin

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
Recurring date formula Mc/[_2_] Excel Worksheet Functions 5 April 2nd 23 07:45 PM
How to build effective IF Statement for recurring value in cells....sensitivity analysis [email protected] Excel Discussion (Misc queries) 1 March 30th 07 09:14 PM
Counting recurring cells Peter[_61_] Excel Programming 8 December 27th 06 08:34 PM
Recurring Excel Formula error - multiple users affected! Rayo K Excel Discussion (Misc queries) 3 April 11th 06 02:22 PM
Formula to compare two lists and separate non-recurring items? Tennessee Excel Worksheet Functions 2 November 10th 05 06:32 PM


All times are GMT +1. The time now is 12:50 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"