LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Confusing Macro and references....


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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Confusing results Papa Jonah Excel Worksheet Functions 5 March 5th 10 10:38 PM
Menu confusing marriedhsdad New Users to Excel 3 January 18th 10 04:20 PM
Confusing Function Chris C Excel Worksheet Functions 4 November 5th 08 06:41 PM
V-/H- LOOKUP still confusing Andreas B Excel Worksheet Functions 3 June 5th 08 02:54 PM
VLookup confusing jag53 Excel Worksheet Functions 4 June 28th 07 04:26 PM


All times are GMT +1. The time now is 02:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"