InStr, vbTextCompare, Last.Collumn

jvdherik010

New Member
Joined
Dec 30, 2016
Messages
13
hi all,

i am busy with an formula, for a quite big project.

i use this code:

Code:
V_End_Of_Table = ActiveSheet.UsedRange.Rows.Count
Dim cell As Range



For Each cell In Range("CA2:CA" & V_End_Of_Table)
If InStr(1, [SUB]cell.Value[/SUB], "fcnswanlrtm", vbTextCompare) > 0 Then
        
        Range("CX" & cell.Row).Value = "FCNSWANLRTM"

    Else
       
    End If
    
Next

the thing is that i have alot of these "codes" like FCNSWANLRTM, and all are different.


i need to find a code that he is searching InStr for "FCN", and then
.value needs to be that "FCN" + 8 characters on the right put in a certain cell in that row.


but i have another challenge..

1 cell can look like:
FCNCANNLRTM
FCNFOCNLRTM
FCNFOSNLRTM
FCNHUANLRTM
FCNLYGNLRTM
fcnmainnlrtmfcnfosnlrtm
FCNNGBNLRTM
FCNNTGNLRTM

<colgroup><col></colgroup><tbody>
</tbody>

and i need every "code"




what i think i need is an Instr searched for "FCN", and the value is "FCN" + 8 characters on the right _
copied to the last.collumn of the sheet.. but on that same row..


here the link to my file
https://www.dropbox.com/s/t4485ztfux5oj9r/test havens.xlsm?dl=0




i hope someone can help me:)
 
Code:
Sub Test()
Dim c As Range, d As Long
For Each c In Range("CA2:CA" & Range("CA" & Rows.Count).End(xlUp).Row)
    d = 0
    With CreateObject("vbscript.regexp")
        .Pattern = "FCN.{8}"
        .IgnoreCase = True
        .Global = True
        If .Test(c.Text) Then
            Set m = .Execute(c.Text)
            For Each i In m
                Range("DA" & c.Row).Offset(, d) = UCase(i)
                d = d + 1
            Next
        End If
    End With
Next
End Sub


wow, perfect..
thank you so much, that means a breakthrough.

just 1 last final question.

is it possible to have a pattern like.
F{5}NLRTM ?
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Do you mean F followed by any 5 characters then NLRTM or do you mean 5 Fs followed by NLRTM?
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,684
Members
449,116
Latest member
HypnoFant

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