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

I am trying to create a vba routine to read a text string in a particular
cell, then search for that text string in a range of cells and then copy and
paste another range into a location starting one cell to the right of the
found text string. I also need to do the reverse in retrieving the data
previously pasted, into the location of the original range. Basically like a
database operation of fetching and updating records. I can't use a lookup on
the pasted data because I have to modify it and then update the 'database'. I
have been trying doing this with a €˜find procedure but it seems like the
find will not get the search string from a referenced cell, only data
programmed in the code. By the way, the search string is coming from
selection from a validation drop down list placed in a particular cell. Does
anyone have any good ideas how to do this?
Thanks in advance,
RD Wirr
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Find String Excel VBA

Worksheets("Sheet1").Activate
set rng = range("B1:B30").find(What:=Range("J10").value, _
After:=Range("B30"), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)

if not rng is nothing then
worksheets("Sheet2").Range("F11").copy rng.offset(0,1)
else
msgbox "Target not found"
End if


should work fine. So your premise that it won't use a value stored in a
range is flawed.

--
Regards,
Tom Ogilvy



"RD Wirr" wrote in message
...
I am trying to create a vba routine to read a text string in a particular
cell, then search for that text string in a range of cells and then copy

and
paste another range into a location starting one cell to the right of the
found text string. I also need to do the reverse in retrieving the data
previously pasted, into the location of the original range. Basically like

a
database operation of fetching and updating records. I can't use a lookup

on
the pasted data because I have to modify it and then update the

'database'. I
have been trying doing this with a 'find' procedure but it seems like the
find will not get the search string from a referenced cell, only data
programmed in the code. By the way, the search string is coming from
selection from a validation drop down list placed in a particular cell.

Does
anyone have any good ideas how to do this?
Thanks in advance,
RD Wirr



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Find String Excel VBA

That worked well Tom. Thanks.

RDW

"Tom Ogilvy" wrote:

Worksheets("Sheet1").Activate
set rng = range("B1:B30").find(What:=Range("J10").value, _
After:=Range("B30"), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)

if not rng is nothing then
worksheets("Sheet2").Range("F11").copy rng.offset(0,1)
else
msgbox "Target not found"
End if


should work fine. So your premise that it won't use a value stored in a
range is flawed.

--
Regards,
Tom Ogilvy



"RD Wirr" wrote in message
...
I am trying to create a vba routine to read a text string in a particular
cell, then search for that text string in a range of cells and then copy

and
paste another range into a location starting one cell to the right of the
found text string. I also need to do the reverse in retrieving the data
previously pasted, into the location of the original range. Basically like

a
database operation of fetching and updating records. I can't use a lookup

on
the pasted data because I have to modify it and then update the

'database'. I
have been trying doing this with a 'find' procedure but it seems like the
find will not get the search string from a referenced cell, only data
programmed in the code. By the way, the search string is coming from
selection from a validation drop down list placed in a particular cell.

Does
anyone have any good ideas how to do this?
Thanks in advance,
RD Wirr




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
how we find specific word from string in excel and compaire it. Vishnu Excel Worksheet Functions 2 April 18th 09 07:51 AM
Excel -find records which DO NOT contain a particular text string JackBuff Excel Discussion (Misc queries) 5 May 23rd 06 05:40 PM
Excel - Find & Replace text in a string bklim Excel Worksheet Functions 1 June 14th 05 06:42 AM
backwards find function to find character in a string of text Ashleigh K. Excel Programming 1 January 14th 04 04:36 PM
Find a string in excel J Excel Programming 2 September 9th 03 07:26 PM


All times are GMT +1. The time now is 03:55 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"