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
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