Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I've done this in Word, but can't seem to get it to work in Excel. I have a
Userform wherein the user types some text (variable1). When the user clicks on the "continue" button I want the code behind that button to Search and Replace the predefined text in the worksheet and replace it with the variable1 text that the user typed. If I record the keystrokes for search and replace, the macros works, but it does not work after putting that code in the button code because I don't know how/where to put the "variable1". In Word, it looked like this: Private Sub CommandButton1_Click() Dim variable1 As String variable1 = FillInDate.DateBox.Text Cells.Find(What:="C4", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False) _ .Activate Cells.Replace What:="C4", Replacement:="C5", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False <<< Any help out there? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Search and replace | Excel Worksheet Functions | |||
Search and replace | Excel Discussion (Misc queries) | |||
Search and Replace | Excel Discussion (Misc queries) | |||
Help with search and Replace | Excel Programming | |||
Variable in a Search and Replace macro | Excel Programming |