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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
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,214,854
Messages
6,121,941
Members
449,056
Latest member
denissimo

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