Hi,
Hoping someone might be able to shed some light on an annomaly I've come across when finding a string in a specified range. I have found a workaround but not really happy with it and want to understand why Excel / VBA is behaving this way as it's not as I would expect. I'm using Excel 2003.
The following code is a simplified version of what I'm using within a bigger project:
Dim fxRng, fxRngAdd
Dim FindString As String
FindString = FXForm1.Controls("Textbox1").Value
With Sheets("Sheet1").Range("B6:B170")
Set fxRng = .Find(What:=FindString, After:=.Cells(.Cells.Count), LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If Not fxRng Is Nothing Then
fxRngAdd = fxRng.Address
.Range(fxRngAdd).Select
End If
End With
The FindString will be a currency (e.g. "EUR") which I want it to find within the range B6:B170 specifically. As I step through the fxRng variable displays "EUR" and the fxRngAdd variable shows $B$6 when I hover the mouse over it. However when it's selected, the cell C11 is the one that's actually selected not B6!?!
I can work around this by changing the Range to "B:B" where it selects C6 instead of B6 then offset back one, but I'd really rather not do it this way - just seems clumsy.
Anyone have any ideas why it's behaving this way? Have I done something dumb in the .Find bit or setting the variables?
Any help appreciated - bugging me.
**EDIT** Added Example Workbook
Thanks, TC
Bookmarks