#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Match

Hi All,

i have value B_12-23

it should match with
B_12-23
B_12 23
B 12 23
B1223

I need vba solution.

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Match

Hi

Maybe this is what you need:

Sub MyMatch()
Set TargetRange = Range("A1:A4")
Set MatchCell = Range("B1")
MatchValue = WorksheetFunction.Match(MatchCell, TargetRange, 0)
MsgBox ("Match is : " & MatchValue)
End Sub

Regards,
Per

"fi.or.jp.de" skrev i meddelelsen
...
Hi All,

i have value B_12-23

it should match with
B_12-23
B_12 23
B 12 23
B1223

I need vba solution.

Thanks in advance.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Match

As I am sure there are other letters and numbers besides "B", "12, and "23"
that you will need to match, then let's call your B_12-23 value Code and
your other possible values TextVal; then your test would be this...

If Replace(Replace(Code, "-", ""), "_", "") = _
Replace(Replace(TextVal, "-", ""), "_", "") Then
MsgBox "They match"
Else
MsgBox "They do not match"
End If

Know though that this is not a foolproof test as TextVal's like B-1_2-2_3
would also show up as matching the Code value B_12-23. Only you know if this
is a "good" enough test as only you know the possible Code and TextVal
values that can be in your data. Other more exacting tests might be
possible, but you would have to tell us about any restraints regarding the
"shape" that the Code and TextVal's could possibly take.

--
Rick (MVP - Excel)


"fi.or.jp.de" wrote in message
...
Hi All,

i have value B_12-23

it should match with
B_12-23
B_12 23
B 12 23
B1223

I need vba solution.

Thanks in advance.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Match

Thanks Rick,

I was waiting on my last post.



On Oct 7, 11:44*am, "Rick Rothstein"
wrote:
As I am sure there are other letters and numbers besides "B", "12, and "23"
that you will need to match, then let's call your B_12-23 value Code and
your other possible values TextVal; then your test would be this...

If Replace(Replace(Code, "-", ""), "_", "") = _
* * *Replace(Replace(TextVal, "-", ""), "_", "") *Then
* MsgBox "They match"
Else
* MsgBox "They do not match"
End If

Know though that this is not a foolproof test as TextVal's like B-1_2-2_3
would also show up as matching the Code value B_12-23. Only you know if this
is a "good" enough test as only you know the possible Code and TextVal
values that can be in your data. Other more exacting tests might be
possible, but you would have to tell us about any restraints regarding the
"shape" that the Code and TextVal's could possibly take.

--
Rick (MVP - Excel)

"fi.or.jp.de" wrote in message

...

Hi All,


i have value B_12-23


it should match with
B_12-23
B_12 23
B 12 23
B1223


I need vba solution.


Thanks in advance.


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
Lookup Formula: Return 1st match, then 2nd match, then 3rd match Scott Excel Discussion (Misc queries) 4 December 11th 09 05:50 AM
Need to match 2 columns, if a match found add info from 2nd column Stratton Excel Worksheet Functions 1 October 8th 08 02:55 PM
index(match) Wind Uplift Calculations (match four conditions) JMeier Excel Worksheet Functions 8 August 1st 08 01:45 AM
MATCH Multiple Criteria & Return Previous / Penultimate Match Sam via OfficeKB.com Excel Worksheet Functions 27 October 6th 07 01:39 AM
Lookup? Match? pulling rows from one spreadsheet to match a text f cjax Excel Worksheet Functions 3 July 21st 06 02:51 PM


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