Marco has stopped working

DownUnder71

New Member
Joined
Aug 6, 2013
Messages
6
Hello forum,

The macro below was working well a week ago. It now comes up with a Run-time error '1004': Unable to get the Average property of the WorksheetFunction class

The debugger indicates the issue lies at the row highlighted red. Any clues/help will be much appreciated.



Sub AssayAverages()
Dim myRange As Range
Dim wsOut As Worksheet
Dim colCount As Long
Dim counter As Long


'Where are we putting the output?
Set wsOut = Worksheets("Sheet1")
Set myRange = Application.InputBox("Select Range", "Interval Assay Average", , , , , , 8)
'How many columns will we do?
colCount = myRange.Columns.Count


Application.ScreenUpdating = False
With wsOut
'Loop through the columns
For counter = 1 To colCount
'Averages
.Cells(2, counter).Columns(10).Value = WorksheetFunction.Average(myRange.Columns(counter))
Next counter
End With
Application.ScreenUpdating = True
End Sub
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
When it stops find the value of counter then go to that column in the worksheet. Does it have error cells within the range you selected via the inputbox? Or is every cell within that range blank? These would both produce that error. There would be an error if you where to use a formula on the worksheet. You could try using Application.Average instead and see what happens.
 
Upvote 0

Forum statistics

Threads
1,224,767
Messages
6,180,847
Members
453,001
Latest member
coulombevin

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