Hi,
I have a sheet with rows of cells with values. In X column I have a formula that looks for the MIN value of these cells and displays it.
The cells in the rows are populated from another sheet that grabs the data from a URL and some jiggery pokery through VBA. The row cells show the average value from a lot of data on another worksheet that is then copied to a "Master" worksheet where Column X does it's MIN formula.
If the average equates to a DIV/0 error I want to be able to show a String like NULL or NULL_ITEMS to stop it throwing the MIN formula out when it's copied across. I've tried all sorts but I can't seem to get it to do this but it will show a 0 using the code below:
I tried adding this in my PUBLIC declarations: Public NULLITEMS As String
And in another module I added: NULLITEMS = "Null Items"
To try this:
This didn't work and I don't know why. Any help greatly appreciated as this is throwing my MIN values right out along with what little hair I have left.
Thank you and sorry for the long blurb.
Mark.
EDIT:
The entire code I'm using to manipulate this data on another sheet before copying to the "Master" is below for reference:
I have a sheet with rows of cells with values. In X column I have a formula that looks for the MIN value of these cells and displays it.
The cells in the rows are populated from another sheet that grabs the data from a URL and some jiggery pokery through VBA. The row cells show the average value from a lot of data on another worksheet that is then copied to a "Master" worksheet where Column X does it's MIN formula.
If the average equates to a DIV/0 error I want to be able to show a String like NULL or NULL_ITEMS to stop it throwing the MIN formula out when it's copied across. I've tried all sorts but I can't seem to get it to do this but it will show a 0 using the code below:
Code:
'Removes #DIV/0! Errors
For Each DIVRange In Selection
If IsError(DIVRange.Value) Then
If DIVRange.Value = CVErr(xlErrDiv0) Then DIVRange.Value = 0
End If
Next DIVRange
I tried adding this in my PUBLIC declarations: Public NULLITEMS As String
And in another module I added: NULLITEMS = "Null Items"
To try this:
Code:
'Removes #DIV/0! Errors
For Each DIVRange In Selection
If IsError(DIVRange.Value) Then
If DIVRange.Value = CVErr(xlErrDiv0) Then DIVRange.Value = NULLITEMS
End If
Next DIVRange
This didn't work and I don't know why. Any help greatly appreciated as this is throwing my MIN values right out along with what little hair I have left.
Thank you and sorry for the long blurb.
Mark.
EDIT:
The entire code I'm using to manipulate this data on another sheet before copying to the "Master" is below for reference:
Code:
'Clears Row 11
Rows("11:11").ClearContents
'Creates an Average of All Cells Above Range Set
Range("C11").Select
ActiveCell.FormulaR1C1 = "=AVERAGE(R[-10]C:R[-1]C)"
'Removes #DIV/0! Errors
For Each DIVRange In Selection
If IsError(DIVRange.Value) Then
If DIVRange.Value = CVErr(xlErrDiv0) Then DIVRange.Value = 0
End If
Next DIVRange
'Sets the Value to the Variable
VALUE = Cells(11, "C")
Sheets("MASTER").Select
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = VALUE
Last edited: