Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to write some code for Excel that takes the selected value of a
cell on one sheet and searches for it on a second sheet ("Data") in the same workbook, but within a specific range around the active cell on the second sheet. My code selects the range on the second sheet without a problem but errors when attempting to use the find method. Here's the code: Sub ToData() Dim SearchTarget As String Dim RngTop, RngBot As Integer SearchTarget = Selection 'active cell on sheet 1 Worksheets("Data").Activate RngRow = ActiveCell.Row 'demarcates range RngBot = Cells(RngRow, 3).End(xlDown).Row RngTop = Cells(RngRow, 3).End(xlUp).Row Set Rng = Range("A" & RngTop, "A" & RngBot) Rng.Select 'if the last line containing the Find function is omitted, the range is selected as intended 'when the following Find is added, an error occurs Rng.Find(What:=SearchTarget, LookAt:= _ xlPart, SearchDirection:=xlNext, MatchCase:=False).Activate End Sub Thanks for the help! Greg |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how can find sheet on workbook have so many sheet ? | Excel Worksheet Functions | |||
Find data from one sheet in another sheet | Excel Worksheet Functions | |||
find a sheet | Excel Discussion (Misc queries) | |||
Find A Value In Sheet? | Excel Discussion (Misc queries) | |||
Find changes and add them to the new sheet | Excel Programming |