Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default VBA Cell Filtering with conditions

Hello,

Is there way to have Excel retain everything in a cell that is between
quotation marks ("") and contains an underscore ( _ ) and delete
everything else that does not match this condition. I'd like the
results returned to the column/cell beside the original. The cell
character length is greater that 255 (limitation of countif)? I'm
analyzing SQL statements.

For example: (keep in mind, this example has less than 255 characters
per cell, but I need this to work for cell over 255 characters)

A1
"dog" cat "horse_mule" pig

would return

B1
"horse_mule"


Again, any suggestions/solutions would be greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default VBA Cell Filtering with conditions

Craig,

Try the following function:

Function ParseIt(S As String) As String

Dim Ndx As Long
Dim Arr As Variant
Arr = Split(S, " ")
For Ndx = LBound(Arr) To UBound(Arr)
If Left(Arr(Ndx), 1) = """" And Right(Arr(Ndx), 1) = """"
Then
If InStr(Arr(Ndx), "_") 0 Then
ParseIt = Arr(Ndx)
Exit Function
End If
End If
Next Ndx

End Function

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Craig Freeman" wrote in message
om...
Hello,

Is there way to have Excel retain everything in a cell that is
between
quotation marks ("") and contains an underscore ( _ ) and
delete
everything else that does not match this condition. I'd like
the
results returned to the column/cell beside the original. The
cell
character length is greater that 255 (limitation of countif)?
I'm
analyzing SQL statements.

For example: (keep in mind, this example has less than 255
characters
per cell, but I need this to work for cell over 255 characters)

A1
"dog" cat "horse_mule" pig

would return

B1
"horse_mule"


Again, any suggestions/solutions would be greatly appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default VBA Cell Filtering with conditions

Hi Chip,

Thanks for your help, and your function does work, but it seems to only
return the first incident of condition. I was hoping to retrieve all
results that match this condition ("_")with the cell. Is there a way
this function could be modified?

thanks again,
Craig Freeman

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
Countif Conditions - Use of conditions that vary by cell value JonTarg Excel Discussion (Misc queries) 1 May 30th 08 01:21 PM
Conditional formatting Based on cell A text with conditions in Cell B Raicomm Excel Discussion (Misc queries) 0 January 21st 08 04:46 PM
Filtering Referenced Cell UT Excel Discussion (Misc queries) 1 July 14th 07 02:00 AM
filtering based on a value in a cell John E. Fox Excel Worksheet Functions 1 December 13th 06 01:42 AM
trouble filtering a list. Why isn't column filtering? Pat Excel Worksheet Functions 1 July 18th 05 03:30 PM


All times are GMT +1. The time now is 07:12 AM.

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"