lionginass
New Member
- Joined
- Jul 29, 2016
- Messages
- 24
Hello,
I' am trying to create a formula to find a first value in a row with VBA.
My code:
Function Secret(Qty As Range)
x = Qty.Find("*", , xlValues, xlWhole, xlByRows, xlNext, False, False, False).Value
Secret = x
End Function
Lets say i select range A1:G1 (Qty = A1:G1)
Values are: A1 = 5; D1 = 2; G1 = 8
My formula returns 2 instead of 5. Anyone has an idea why?
It is something wrong with A1, because if i delete 5 from A1 and enter it in B1, then formula returns 5 which is correct.
I had an idea that search function doesn't count the first cell in a range, but if I delete all other values and enter only 5 in A1; then formula returns 5.
If i want to search the last value in a row, then i change xlNext to xlPrevious, and then formula returns 8, which is correct,
so this issue is only when i try to find first value and something is strange with first cell
Cant find any help regarding this in internet.. seems like obvious thing but is to difficult for beginner
thanks for help
I' am trying to create a formula to find a first value in a row with VBA.
My code:
Function Secret(Qty As Range)
x = Qty.Find("*", , xlValues, xlWhole, xlByRows, xlNext, False, False, False).Value
Secret = x
End Function
Lets say i select range A1:G1 (Qty = A1:G1)
Values are: A1 = 5; D1 = 2; G1 = 8
My formula returns 2 instead of 5. Anyone has an idea why?
It is something wrong with A1, because if i delete 5 from A1 and enter it in B1, then formula returns 5 which is correct.
I had an idea that search function doesn't count the first cell in a range, but if I delete all other values and enter only 5 in A1; then formula returns 5.
If i want to search the last value in a row, then i change xlNext to xlPrevious, and then formula returns 8, which is correct,
so this issue is only when i try to find first value and something is strange with first cell
Cant find any help regarding this in internet.. seems like obvious thing but is to difficult for beginner

thanks for help