Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I would like to know how do i create a macro the will copy what i have in cell A1 or inputbox and search it for me. Eg. Cell A1 consist of text "Apple" when click on the button, it will find Apple. If it is "Orange" it will find orange. I do remember creating it once but have forget about it. Any advise. Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try
Sub Macro() Dim varFound As Variant, varSearch As Variant varSearch = Range("A1") Set varFound = Cells.Find(varSearch, _ After:=Range("A1"), LookIn:=xlValues, lookat:=xlWhole) If varFound.Address < "$A$1" Then varFound.Select Else MsgBox "Search string '" & Range("A1") & "' could not be found" End If End Sub -- Jacob (MVP - Excel) "AndrewT" wrote: Hi, I would like to know how do i create a macro the will copy what i have in cell A1 or inputbox and search it for me. Eg. Cell A1 consist of text "Apple" when click on the button, it will find Apple. If it is "Orange" it will find orange. I do remember creating it once but have forget about it. Any advise. Thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks.
But is there a way for me input it using the inputbox for search? "Jacob Skaria" wrote: Try Sub Macro() Dim varFound As Variant, varSearch As Variant varSearch = Range("A1") Set varFound = Cells.Find(varSearch, _ After:=Range("A1"), LookIn:=xlValues, lookat:=xlWhole) If varFound.Address < "$A$1" Then varFound.Select Else MsgBox "Search string '" & Range("A1") & "' could not be found" End If End Sub -- Jacob (MVP - Excel) "AndrewT" wrote: Hi, I would like to know how do i create a macro the will copy what i have in cell A1 or inputbox and search it for me. Eg. Cell A1 consist of text "Apple" when click on the button, it will find Apple. If it is "Orange" it will find orange. I do remember creating it once but have forget about it. Any advise. Thanks |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try
Sub Macro() Dim varFound As Variant, varSearch As Variant varSearch = InputBox("Enter search string") Set varFound = Cells.Find(varSearch, , xlValues, xlWhole) If Not varFound Is Nothing Then varFound.Select Else MsgBox "Search string '" & varSearch & "' could not be found" End If End Sub -- Jacob (MVP - Excel) "AndrewT" wrote: Thanks. But is there a way for me input it using the inputbox for search? "Jacob Skaria" wrote: Try Sub Macro() Dim varFound As Variant, varSearch As Variant varSearch = Range("A1") Set varFound = Cells.Find(varSearch, _ After:=Range("A1"), LookIn:=xlValues, lookat:=xlWhole) If varFound.Address < "$A$1" Then varFound.Select Else MsgBox "Search string '" & Range("A1") & "' could not be found" End If End Sub -- Jacob (MVP - Excel) "AndrewT" wrote: Hi, I would like to know how do i create a macro the will copy what i have in cell A1 or inputbox and search it for me. Eg. Cell A1 consist of text "Apple" when click on the button, it will find Apple. If it is "Orange" it will find orange. I do remember creating it once but have forget about it. Any advise. Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
macro to create a new workbook/ macro to copy columns | Excel Programming | |||
macro to create, name sheet and copy. | Excel Discussion (Misc queries) | |||
create a macro to copy a worksheet into another | Excel Discussion (Misc queries) | |||
create macro to copy | Excel Discussion (Misc queries) | |||
Create a Macro that will copy the rows that have a value < 0 | Excel Discussion (Misc queries) |