Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA Code to FIND

Hello all, thanks in advance for your assistance.

I am using a macro to look up a value, find that value in another
sheet, then copy from that row to another workbook.

Clear as mud? The problem in, the value will not always be the same.
But the code puts the value, not the fact that I pasted the value,
into the FIND value. See below:

Selection.Find(What:="MI071001", After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate

The value "MI071001" will not always be the same. I want it to find
the value and paste it into Find each time it runs. Does this make
sense?

Christine
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default VBA Code to FIND

Christine,

Have you tried:

Dim sSearchText as String

.... at some point in the program:
sSearchText = "MI071001" -- or pick it up from a cell, or an InputBox,
or an array or .....

..... and then:
Selection.Find(What:=sSearchText, After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate

HTH,

Alex@JPCS

"Christine" wrote in message
om...
Hello all, thanks in advance for your assistance.

I am using a macro to look up a value, find that value in another
sheet, then copy from that row to another workbook.

Clear as mud? The problem in, the value will not always be the same.
But the code puts the value, not the fact that I pasted the value,
into the FIND value. See below:

Selection.Find(What:="MI071001", After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate

The value "MI071001" will not always be the same. I want it to find
the value and paste it into Find each time it runs. Does this make
sense?

Christine



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA Code to FIND

Alex,

Thanks a bunch. However, I think I need a SET statement too, don't I?
(At least that's what I gather for the error message I get.) How does
the SET statement work?

Thanks again,

The VBA Neophyte
Christine



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA Code to FIND

You should be able to use a variable instead of the actual
value assuming the value you want to find exist in cell
(1,1) of the activesheet then:


StrMyVar = ActiveSheet.Cells(1,1)

Selection.Find(What:=StrMyVar, After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate


Hope this helps if you had'nt already figured it out.

Alex-






-----Original Message-----
Hello all, thanks in advance for your assistance.

I am using a macro to look up a value, find that value in

another
sheet, then copy from that row to another workbook.

Clear as mud? The problem in, the value will not always

be the same.
But the code puts the value, not the fact that I pasted

the value,
into the FIND value. See below:

Selection.Find(What:="MI071001", After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate

The value "MI071001" will not always be the same. I want

it to find
the value and paste it into Find each time it runs. Does

this make
sense?

Christine
.

Reply
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
VBA Code - Find & Move Youlan Excel Discussion (Misc queries) 4 October 28th 08 07:26 PM
Find a range using code Jonathan Brown Excel Worksheet Functions 3 October 1st 08 12:02 PM
Code to find code D. Excel Discussion (Misc queries) 2 August 12th 07 06:16 PM
Find last row code Mike Milmoe Excel Discussion (Misc queries) 2 June 11th 07 08:48 PM
How do I find a code in Excel Terranoman Excel Worksheet Functions 4 May 18th 07 02:29 PM


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

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

About Us

"It's about Microsoft Excel"