Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Macro to copy text between delimeters

I am trying to write a macro in Excel to select text between cells
which contain words.

Two challenges:
1.) I need to search for a cell that contains only one-single word
"item:" and then copy the contents of the cell just-above that cell
2.) I need to search for a cell that contains only one-single word
"component(s):" and then copy all of the rows below that until I find
a cell that contains only the word "Zip"


Any samples would help for either of these challenges
~Vic

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Macro to copy text between delimeters

On Apr 6, 7:14 am, "Vic" wrote:
I am trying to write a macro in Excel to select text between cells
which contain words.

Two challenges:
1.) I need to search for a cell that contains only one-single word
"item:" and then copy the contents of the cell just-above that cell
2.) I need to search for a cell that contains only one-single word
"component(s):" and then copy all of the rows below that until I find
a cell that contains only the word "Zip"

Any samples would help for either of these challenges
~Vic


Vic,

You can use the Find function, the Offset Property, and the Row or
Address property to find the data that you are looking for. (The code
has not been tested).

In order to offset from "item:" you can right something like
itemOffset = Columns("a").Find(What:="item:").Offset(-1,0).Value

You can use the same idea to find the row locations of "component(s):"
and "Zip"
compRow = Columns("a").Find(What:="component(s):").Row
zipRow = Columns("a").Find(What:="Zip").Row
You can then copy the data inbetween the Rows/Addresses.

The macro recorder will give you a Cells.Find when you record the Find
option; however, don't be afraid to change "Cells" to a more specific
location. Also, the Find function has a FindNext parameter (and there
is a FindNext method) that will assist you if you have multiple words
to find.

Matt

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro to copy text between delimeters

You have a response at your other post, too.

Vic wrote:

I am trying to write a macro in Excel to select text between cells
which contain words.

Two challenges:
1.) I need to search for a cell that contains only one-single word
"item:" and then copy the contents of the cell just-above that cell
2.) I need to search for a cell that contains only one-single word
"component(s):" and then copy all of the rows below that until I find
a cell that contains only the word "Zip"

Any samples would help for either of these challenges
~Vic


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Macro to copy text between delimeters

On Apr 6, 7:55 am, "matt" wrote:
On Apr 6, 7:14 am, "Vic" wrote:

I am trying to write a macro in Excel to select text between cells
which contain words.


Two challenges:
1.) I need to search for a cell that contains only one-single word
"item:" and then copy the contents of the cell just-above that cell
2.) I need to search for a cell that contains only one-single word
"component(s):" and then copy all of the rows below that until I find
a cell that contains only the word "Zip"


Any samples would help for either of these challenges
~Vic


Vic,

You can use the Find function, the Offset Property, and the Row or
Address property to find the data that you are looking for. (The code
has not been tested).

In order to offset from "item:" you can right something like
itemOffset = Columns("a").Find(What:="item:").Offset(-1,0).Value

You can use the same idea to find the row locations of "component(s):"
and "Zip"
compRow = Columns("a").Find(What:="component(s):").Row
zipRow = Columns("a").Find(What:="Zip").Row
You can then copy the data inbetween the Rows/Addresses.

The macro recorder will give you a Cells.Find when you record the Find
option; however, don't be afraid to change "Cells" to a more specific
location. Also, the Find function has a FindNext parameter (and there
is a FindNext method) that will assist you if you have multiple words
to find.

Matt


Thank you.
I did the simpler of the two scenarios and it worked great. I cannot
understand once i have both compRow and zipRow how to select and copy
the text in-between the two.

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
Macro to copy text between two different delimeters [email protected] New Users to Excel 1 April 6th 07 03:54 PM
Find a string between two delimeters and replace with text Jeff[_50_] Excel Programming 2 May 2nd 06 07:15 PM
copy text from 1 workbook to another by macro bigdaddy3 Excel Worksheet Functions 0 August 17th 05 06:20 PM
Macro to copy only certain text Melissa[_2_] Excel Programming 3 August 3rd 04 07:49 PM
Import text file into excel with preset file layout, delimeters VBA meldrape Excel Programming 7 June 15th 04 08:31 PM


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