Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I trying to create a small macro to look up a value typed in a textbox using
the following code. If I try to set the variable S to the value of TextBox1 the find does not return anything. If I set S to the actual value then the find is successful. Private Sub CommandButton1_Click() Dim strRange As String Dim strMyString As String Dim rngFound As Range MyString = TextBox1.Value Set rngFound = Sheets("Dealership Report").Cells.Find(MyString, , , xlPart) ' TextBox1.Value = 240599 , actual value entered in text box S = TextBox1.Value Set SearchRange = Worksheets("sheets 1").Range("A1:A3671") Set c = SearchRange.Find(What:=S, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False) If c Is Nothing Then MsgBox "Not found" Else strRange = c.Address Range(strRange).Activate MsgBox "Found" End If End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Variable Find | Excel Discussion (Misc queries) | |||
3 variable find and replace | Excel Discussion (Misc queries) | |||
Find with a variable | Excel Programming | |||
Find a variable | Excel Programming | |||
Cells.Find error Object variable or With block variable not set | Excel Programming |