Range a1:iv1 (the entire top row), simply contains the column heading names A,B,C...AA,AB... IT,IU, IV (all possible 256 column names)
Range a2:iv2 contains the series of numbers 1 through 256
If you key in "B", the message box tells you "2"
If you key in "2", the message box tells you "B"
This is my own beginner's exercise.
The following code seems to work for everything except the very first cell in the range.
If I key in "A" the code returns 27, which is actually "AA".
If I key in "1" the code returns "J" (so it is finding the leading numeral 1 in 10).
The code is not searching the first cell in the range.
How may I modify this code to include the first cell (A1)?
Code
Dim c As Range
arg = Trim(TextBox1.Value)
If IsNumeric(arg) Then
With Worksheets(1).Range("a2:iv2")
Set c = .Find(arg, LookIn:=xlValues)
If Not c Is Nothing Then
MsgBox "Column " & c.Offset(-1, 0).Value & " Is equal to " & TextBox1.Value
Else
MsgBox TextBox1.Value & " not found!"
End If
End With
Else
With Worksheets(1).Range("a1:iv1")
Set c = .Find(TextBox1.Value, LookIn:=xlValues)
If Not c Is Nothing Then
MsgBox "Column " & TextBox1.Value & " is equal to " & c.Offset(1, 0).Value
Else
MsgBox TextBox1.Value & " not found1"
End If
End With
End If
TextBox1.Value = ""
TextBox1.SetFocus
Display More