Code that searches from right to left for the first cell with a value greater than zero
Posted on 2011-09-19
I need some code that will define the variable "y" not as the first cell to the left of the last column, but rather the first cell to the left with a value greater than zero.
I was using this until I discovered that the searched for cell sometimes contained a zero:
Set y = ActiveWorkbook.ActiveSheet.Cells(x, 256).End(xlToLeft)
If there's no simple way to accomplish my goal with a simple modification of the above, then something of this sort might work but of course I need it to start looking left from the last column and I need it to find the first value that is NOT zero:
Set y = Rows("2:2").Find(What:="0", After:=Cells(2, 256), LookIn:=xlValues, searchdirection:=xlToLeft)
I thought that this might search backward from Column IV but of course it doesn't.