Range count average .

Sunline

Well-known Member
Joined
Oct 6, 2007
Messages
701
Office Version
  1. 2016
Platform
  1. Windows
Hello all ,
In this workbook , I have 3 x macros that are range counting cols BJ , BL , BM , one macro for each .
These work fine , they are able to look in col F that there are so many cells in this range defined by the number in col F .
Col F number is random .
I also have a macro that I did have working many years ago that could average a range . Now it stops on this row highlited in yellow .
MyAverage = Application.WorksheetFunction.Average(Myrange)
Can not find an old sheet that the average macro worked in , so here for any advise . Buttons up the top . Cols U V W have these macros results .
Thanks . Cant seem to get Wikifortio to download my sheet , anyone know of another .
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Unable to send a sheet so will do it this way .
sheet1.xlsm
AFIJKLUVWBJBLBN
1IDFszR1R2R3R1R2R31p2p3p
217422835169
3274228351237
437422835822
547422835425
657422835532
767422835252
8774228351078
981227211132
10912272111452
111012272111935
1211122721115114
131212272111
1413122721113
151412272111
161512272111
171612272111
181712272111
191812272111
2019122721113
2120127651767210
222112765176469
232212765176542
2423127651763119
2524127651765P11
262512765176466
272612765176849
282712765176154
292812765176927
302912765176673
31301276517610510
323112765176
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
W1Cell Value<5textNO
W1Cell Value<5textNO
W1Cell Value<5textNO
K1Cell Value<5textNO
K1Cell Value<5textNO
K1Cell Value<5textNO


Sub SubTotalingBJ()
Dim WS As Worksheet
Dim LR As Long
Dim i As Long
Dim RptCount As Long
Dim MySum As Double
Dim Myrange As Range
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Set WS = ActiveSheet
LR = WS.Range("F" & Rows.Count).End(xlUp).Row

i = 2
Do
If i > LR Then Exit Do
If RptCount = 0 Then
RptCount = WS.Cells(i, 6)
Set Myrange = WS.Range("BJ" & i & ":BJ" & i + RptCount - 1)
MySum = Application.WorksheetFunction.Sum(Myrange)

End If
WS.Cells(i, 9) = MySum
i = i + 1
RptCount = RptCount - 1
Loop
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,038
Messages
6,122,798
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top