I have an excel file with a column full of numbers (occasionally there will be some text or a blank cell) for example
4
5
10
13
5
4
not applicable
9
2
1
6
I want to apply a function to that cell that does the following. If the cell value is blank or text do nothing. If the value is less that 8 then make it 8, if it is greater than or equal to 8 do nothing. So my example column would become:
8
8
10
13
8
8
not applicable
9
8
8
8
I wish to overwrite the values in the cell with the new values as opposed to preserving the original values that were in the cell.
Of course I could do =max(cell, 8) and then just copy the output down the column and the copy/paste values over the top of the column but I need to do this for multiple columns on a sheet (100's of times) so I need a good way to do this.
So far I have managed to write a macro that iterates through my sheet and selects the columns I need to update but I don't know how to actually update them.
Can I define a function and then apply it to each cell in a column? Is there a faster/more efficient way to do this.
EDIT
Code so far:
Sub updatemin()
Dim i, updatecol As Integer
updatecol = 14
For i = 1 To 100
Columns(updatecol).Select
'need to figure out how to make any values less than 8 into 8 for the cells in the given range before moving on to the next column to do the same.
updatecol = updatecol + 22
Next i
End Sub

