Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
KR KR is offline
external usenet poster
 
Posts: 121
Default pulling from 'line' inside cell- best way to reference in VBA?


I have a worksheet where the user uses one row for an item; each item can
have zero to about 6 subitems that these users put each subitem (say, in
column G) on separate lines for readability using <cntl-enter.

They've asked me to use VBA code to detect a certain type of entry (with a
userform, so they can select what type of entry to search for). When that
entry is found, they want me to pull _just_ the corresponding line from
Column H.

Basically;
------------------------------------
Item SubitemA DetailA
SubitemB DetailB
SubitemC DetailC
-------------------------------------
Item SubitemA DetailA
SubitemB DetailB
SubitemC DetailC
-------------------------------------

So if the select Subitem B, I should pull each Detail B and pull it over to
the report I'm creating.

Right now, I'm cycling through each cell to see if DetailB is present, then
trying to parse based on how many returns are in the cell... is there a
better/easier way? Has anyone done this before that could provide a code
snippet for me to test and adapt?

Many Thanks,
Keith

--
The enclosed questions or comments are entirely mine and don't represent the
thoughts, views, or policy of my employer. Any errors or omissions are my
own.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default pulling from 'line' inside cell- best way to reference in VBA?

It might make it easier to parse if you used split() (added in xl2k) to separate
the entries based on vblf's.

Then you could loop through the array looking for what you want.

instr() may help you look through the original string first.

KR wrote:

I have a worksheet where the user uses one row for an item; each item can
have zero to about 6 subitems that these users put each subitem (say, in
column G) on separate lines for readability using <cntl-enter.

They've asked me to use VBA code to detect a certain type of entry (with a
userform, so they can select what type of entry to search for). When that
entry is found, they want me to pull _just_ the corresponding line from
Column H.

Basically;
------------------------------------
Item SubitemA DetailA
SubitemB DetailB
SubitemC DetailC
-------------------------------------
Item SubitemA DetailA
SubitemB DetailB
SubitemC DetailC
-------------------------------------

So if the select Subitem B, I should pull each Detail B and pull it over to
the report I'm creating.

Right now, I'm cycling through each cell to see if DetailB is present, then
trying to parse based on how many returns are in the cell... is there a
better/easier way? Has anyone done this before that could provide a code
snippet for me to test and adapt?

Many Thanks,
Keith

--
The enclosed questions or comments are entirely mine and don't represent the
thoughts, views, or policy of my employer. Any errors or omissions are my
own.


--

Dave Peterson
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
Pulling a cell reference--clickable cells? Bermie Excel Worksheet Functions 1 April 16th 10 09:33 AM
Reference text in a cell inside a formula to specify a sheet name navel151 Excel Worksheet Functions 5 February 20th 10 07:47 AM
How 2 Link DATA instead of CELL REFERENCE - Pulling My Hair Out! NineuhtOK New Users to Excel 6 June 8th 07 10:44 PM
How do I insert a new line of text inside a cell thudson New Users to Excel 4 April 3rd 06 06:08 PM
Creating a Checkbox inside a cell for each line Randy Reese Excel Programming 2 March 4th 04 02:45 AM


All times are GMT +1. The time now is 09:11 AM.

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"