Please addvise on code changes

DaveUK

Board Regular
Joined
Jan 24, 2005
Messages
245
I was given thi code but want to check if a cell contains the characters "ML"'

The string would be for example "235ML" or "126ML" but there could be others.

So i need to check for the cell containing the string "ML" and adapt it to the code below.


Code:
Sub Dave()
Dim I As Long
Dim LR As Long

Const FR As Long = 3    'first row
Const CC As Integer = 4 'check column
LR = Cells(Rows.Count, CC).End(xlUp).Row

For I = FR To LR
    If Cells(I, 4) = "221JB" Then
        If Cells(I, 1) = "Minor" Then Cells(I, 15) = "JOHN W"
        If Cells(I, 1) <> "Minor" And Cells(I, 16) = "B1" Or Cells(I, 16) = "B2" _
        Or Cells(I, 16) = "T1" Or Cells(I, 16) = "T2" Then Cells(I, 15) = "PAUL"
    Else
        If Cells(I, 4) = "935JB" Then Cells(I, 15) = "JOHN G"
    End If
Next I


End Sub

I hope that makes sense and Thanks for any help given.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hello,

Not sure exactly where you want this to fit into your logic, but how about ..

Code:
Sub Dave()
Dim I As Long
Dim LR As Long

Const CC As Integer = 4 'check column

For I = 3 To Cells(Rows.Count, CC).End(xlUp).Row
    If Cells(I, 4) = "221JB" Then
        If Cells(I, 1) = "Minor" Then Cells(I, 15) = "JOHN W"
        If Cells(I, 1) <> "Minor" And Cells(I, 16) = "B1" Or Cells(I, 16) = "B2" _
        Or Cells(I, 16) = "T1" Or Cells(I, 16) = "T2" Then Cells(I, 15) = "PAUL"
    ElseIf
        If Cells(I, 4) = "935JB" Then Cells(I, 15) = "JOHN G"
'************************************************
    ElseIf InStr(1, Cells(I, 4), "ML") > 0 Then
'************************************************
        '.. perform something here
    End If
Next I


End Sub
 
Upvote 0

Forum statistics

Threads
1,215,480
Messages
6,125,049
Members
449,206
Latest member
Healthydogs

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