Find Cell Based Off Columns and Rows in VBA

Converemon

New Member
Joined
May 23, 2014
Messages
15
Hello everyone,

I have been working on a project for a while now and I am near the end, but I have hit a few walls. I do have a few problems, but I will begin with the one I believe to be the simplest. I have two sheets with data. One sheet has a "MLFB" number and option codes. These are specific for each product as the numbers will change based on ratings such as kVA, voltage, cells, etc. and the option codes are additional options the customer chooses. The table might be able to explain it better than I can. The user will input the MLFB and option codes into sheet one and my program will run. At this point, I need a function in VBA to match the MLFB to the regular expression, then if it is True, continue down the columns to determine if the 10th digit is K, A, or P. Depending on which turned out to be True, it will store that information. Then after that, the part that I am having problem with, is then matching the option codes and returning the prices. Column 6 states "!L11 | !I24" which means the option codes should NOT have these options, but they do so this would be False. Columns 7 & 8 have "L11" and "I24" which would both be True. It would need to return these prices, preferrably to a sheet I already have created containing other prices which are then stored for calculations.

I have been able to successfully match the string to the regular expression and also determine the 10th digit. I use this code to evaluate the expression for each MLFB in Sheet1:

Code:
Function Test_MLFB(sMLFB, sPattern, Optional blnCase As Boolean) As Boolean
Dim RegX As Object
Dim RegMC
Set objRegX = CreateObject("VBScript.RegExp")
With objRegEx
    .Pattern = sPattern
    .IgnoreCase = blnCase
    If .Test(sMLFB) Then
        Set RegMC = .Execute(sMLFB)
        Test_MLFB = True
    Else
        Test_MLFB = False
    End If
End With
End Function

I hope everything is clear and I hope this is not too long. I really appreciate any help as it is very important this project is successful. Thank you for you time.
[TABLE="width: 500"]
<TBODY>[TR]
[TD]MLFB
[/TD]
[TD]Option Code
[/TD]
[TD]MLFB Mask
[/TD]
[TD]3EG.........[KA].*
[/TD]
[TD]3EG.........[PA].*
[/TD]
[TD]!L11|!I24
[/TD]
[TD]L11
[/TD]
[TD]I24
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 163"]
<TBODY>[TR]
[TD]3EG68080PY520KA0-Z</SPAN>
[/TD]
[/TR]
</TBODY>[/TABLE]
[/TD]
[TD][TABLE="width: 183"]
<TBODY>[TR]
[TD]L11+M03+I24+P67+K22</SPAN>
[/TD]
[/TR]
</TBODY>[/TABLE]
[/TD]
[TD][TABLE="width: 195"]
<TBODY>[TR]
[TD]3EG68080[OPQRS][YZ]520.*</SPAN>
[/TD]
[/TR]
</TBODY>[/TABLE]
[/TD]
[TD].11
[/TD]
[TD].8
[/TD]
[TD]2000
[/TD]
[TD]900
[/TD]
[TD]860
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 163"]
<TBODY>[TR]
[TD]3EG68080PY530KA0-Z</SPAN>
[/TD]
[/TR]
</TBODY>[/TABLE]
[/TD]
[TD][TABLE="width: 183"]
<TBODY>[TR]
[TD]L11+M03+I24+P67+K22</SPAN>
[/TD]
[/TR]
</TBODY>[/TABLE]
[/TD]
[TD][TABLE="width: 195"]
<TBODY>[TR]
[TD]3EG68080[OPQRS][YZ]530.*</SPAN>
[/TD]
[/TR]
</TBODY>[/TABLE]
[/TD]
[TD].11
[/TD]
[TD].8
[/TD]
[TD]1000
[/TD]
[TD]480
[/TD]
[TD]1203
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 163"]
<TBODY>[TR]
[TD]3EG68080PA540KA0-Z</SPAN>
[/TD]
[/TR]
</TBODY>[/TABLE]
[/TD]
[TD][TABLE="width: 183"]
<TBODY>[TR]
[TD]L11+M03+I24+P67+K22</SPAN>
[/TD]
[/TR]
</TBODY>[/TABLE]
[/TD]
[TD][TABLE="width: 195"]
<TBODY>[TR]
[TD]3EG68080[OPQRS][YZ]540.*</SPAN>
[/TD]
[/TR]
</TBODY>[/TABLE]
[/TD]
[TD].11
[/TD]
[TD].8
[/TD]
[TD]1500
[/TD]
[TD]6600
[/TD]
[TD]8600
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][TABLE="width: 195"]
<TBODY>[TR]
[TD]3EG68080[OPQRS][YZ]550.*</SPAN>
[/TD]
[/TR]
</TBODY>[/TABLE]
[/TD]
[TD].11
[/TD]
[TD].8
[/TD]
[TD]3000
[/TD]
[TD]7000
[/TD]
[TD]7900
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][TABLE="width: 195"]
<TBODY>[TR]
[TD]3EG68080[ABCD][YZ]610.*</SPAN>
[/TD]
[/TR]
</TBODY>[/TABLE]
[/TD]
[TD].11
[/TD]
[TD].8
[/TD]
[TD]9000
[/TD]
[TD]2000
[/TD]
[TD]8790
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][TABLE="width: 195"]
<TBODY>[TR]
[TD]3EG68080[OPQRS][ABCD]540.*</SPAN>
[/TD]
[/TR]
</TBODY>[/TABLE]
[/TD]
[TD].11
[/TD]
[TD].8
[/TD]
[TD]9900
[/TD]
[TD]1500
[/TD]
[TD]11234
[/TD]
[TD][/TD]
[/TR]
</TBODY>[/TABLE]
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,223,885
Messages
6,175,179
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top