I was working in a Function that gives me the Column in wich it finds one value. I was having trouble getting it done...But I made it work!!
The ERROR, believe it or not, was that the Find method has issues with finding values in cells which width is too small... Could that be so dumb?
This is the call..
Private Sub CommandButton3_Click()
Direccion = BuscarCol(2)
MsgBox "the cell address is " & Direccion
End Sub
And this is the function...
Function BuscarCol(Fecha As Integer) As String
Dim RangoFech As Range
With Sheets("REGISTRO").Range("A1:IN1")
Set RangoFech = .Find(What:=Fecha, LookIn:=xlValues, LookAt:=xlWhole, SearchDirection:=xlNext, MatchCase:=False)
If Not RangoFech Is Nothing Then
BuscarCol = ConvertToLetter(RangoFech.Column)
End If
End With
End Function
Oh, and I have one more for converting Column numbers to letters, but this never was the problem..
Function ConvertToLetter(iCol As Integer) As String
Dim iAlpha As Integer
Dim iRemainder As Integer
iAlpha = Int(iCol / 27)
iRemainder = iCol - (iAlpha * 26)
If iAlpha > 0 Then
ConvertToLetter = Chr(iAlpha + 64)
End If
If iRemainder > 0 Then
ConvertToLetter = ConvertToLetter & Chr(iRemainder + 64)
End If
End Function
So...can you tell me if that is right? The Find method has that problem?