Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I WAS TRYING TO CREATE THIS EFFECT: ENTER A VALUE (IN THIS EXAMPLE I WAS \"OKCGALTA\") AND CLICK A BUTTON TO RUN A MACRO TO SEARCH A EXCE SHEET ON A NETWORK DRIVE (P:XXX\ABC.XLS) FOR ALL OF THE VALUES, PAST ONLY THE ROWS IN WHICH THE VALUE IS. CURRENTLY, IT ONLY REFERENCES THE CURRENT SHEET (NOT AN EXTERNAL SHEET AND I HAVE TO GO INTO THE MACRO TO ENTER THE VALUE FOR IT TO LOOK FO (NOT BEING ABLE TO TYPE \"OKCGALTA\" IN CELL A1, FOR EXAMPLE TO MAKE I USER FRIENDLY) ANY HELP WOULD BE MUCH APPRECIATED. Sub SearchForString() Dim LSearchRow As Integer Dim LCopyToRow As Integer On Error GoTo Err_Execute LSearchRow = 2 LCopyToRow = 2 While Len(Range("A" & CStr(LSearchRow)).Value) 0 If Range("B" & CStr(LSearchRow)).Value = "OKCGALTA" Then Rows(CStr(LSearchRow) & ":" & CStr(LSearchRow)).Select Selection.Copy Sheets("Sheet2").Select Rows(CStr(LCopyToRow) & ":" & CStr(LCopyToRow)).Select ActiveSheet.Paste LCopyToRow = LCopyToRow + 1 Sheets("Sheet1").Select End If LSearchRow = LSearchRow + 1 Wend Application.CutCopyMode = False Range("A3").Select MsgBox "All matching data has been copied." Exit Sub Err_Execute: MsgBox "An error occurred." End Su -- ween_bo ----------------------------------------------------------------------- ween_boy's Profile: http://www.excelforum.com/member.php...fo&userid=2930 View this thread: http://www.excelforum.com/showthread.php?threadid=49024 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Confusing results | Excel Worksheet Functions | |||
Menu confusing | New Users to Excel | |||
Confusing Function | Excel Worksheet Functions | |||
V-/H- LOOKUP still confusing | Excel Worksheet Functions | |||
VLookup confusing | Excel Worksheet Functions |