IF condition is text not numeric

mattmcclements

New Member
Joined
Apr 15, 2022
Messages
36
Office Version
  1. 2016
Platform
  1. Windows
Hi, in the column "K" an email will flag when =>3, however, I'm trying to change it so IF "L" = "Investigate" it will flag the email instead. This is what I'm currently working with, thank you for any help in advance.
Lates Tracker - Trial (version 1).xlsb
ABCDFGIJKLW
2Person A101/04/20226:01:00 AMOVERTIMENOT LATESun-ThursAaron Johnson0NOT LATE
3Person B203/03/20221:54:00 PM08:00:0005:54:00Tues-SatLee Massey1First one
4Person C306/03/20229:58:00 AM09:00:0000:58:00WG 6-2Joe Westwell1First one
5Person B217/02/20221:53:00 PM08:00:0005:53:00Tues-SatLee Massey21 Away
6Person C316/02/20221:54:00 PM09:00:0004:54:00WG 6-2Joe Westwell21 Away
7Person A115/02/20221:52:00 PM14:00:00NOT LATESun-ThursAaron Johnson0NOT LATE
8Person B201/03/20221:55:00 PM08:00:0005:55:00Tues-SatLee Massey3Investigate
9Person C330/01/202211:57:00 AM09:00:0002:57:00WG 6-2Joe Westwell3Investigate
10Person A101/02/20222:01:00 PM14:00:0000:01:00Sun-ThursAaron Johnson1First one
11Person B202/03/20221:56:00 PM08:00:0005:56:00Tues-SatLee Massey4Investigate
12Person C313/02/202211:27:00 AM09:00:0002:27:00WG 6-2Joe Westwell4Investigate
13Person A109/02/20221:52:00 PM14:00:00NOT LATESun-ThursAaron Johnson1NOT LATE
14Person B208/02/20221:57:00 PM08:00:0005:57:00Tues-SatLee Massey5Investigate
15Person C308/03/20222:00:00 PM09:00:0005:00:00WG 6-2Joe Westwell5Investigate
16Person B202/02/20221:56:00 PM08:00:0005:56:00Tues-SatLee Massey6Investigate
17Person C310/02/20221:54:00 PM09:00:0004:54:00WG 6-2Joe Westwell6Investigate
18Person B208/02/20226:01:00 AM08:00:00NOT LATETues-SatLee Massey6NOT LATE
19Person A114/03/20226:05:00 AM08:00:00NOT LATESun-ThursAaron Johnson1NOT LATE
20Person B229/03/20226:01:00 AM08:00:00NOT LATETues-SatLee Massey6NOT LATE
21Person C313/04/20226:01:00 AM09:00:00NOT LATEWG 6-2Joe Westwell6NOT LATE
Lates
Cell Formulas
RangeFormula
F2:F21F2=IF(Lates!I2=Master!$D$2,VLOOKUP(Lates!E2,Master!$K$2:$L$8,2,FALSE),VLOOKUP(B2,Master!$C$2:$I$1008,7,FALSE))
G2:G21G2=IF(D2>F2,D2-F2,"NOT LATE")
I2:I21I2=INDEX(Master!$D$2:$D$1332,MATCH(B2,Master!$C$2:C1007,0))
J2:J21J2=IF(I2=$O$2,"Joe Westwell",IF(I2=$O$3,"Aaron Johnson",IF(I2=$O$5,"Gareth Roberts",IF(I2=$O$6,"Steven Jones",IF(I2=$O$4,"Lee Massey",IF(I2=$O$7,"Malcolm Wright",IF(I2=$O$9,"Craig Jones",IF(I2=$O$8,"Lukasz Pawlik",IF(I2=$O$10,"Mike Moffatt",IF(I2=$O$11,"MANAGER",IF(I2=$O$12,"Gary Lee",IF(I2=$O$13,"Gary Lee",IF(I2=$O$14,"Mark Wright")))))))))))))
K2:K21K2=COUNTIFS($B$2:B2,B2,$H$2:H2,"LATE")
L2:L21L2=IF(H2=$S$1,"NOT LATE",IF(K2>=3,"Investigate",IF(K2=2,"1 Away",IF(K2=1,"First one"))))
A2:A21A2=IFERROR(INDEX(Master!$F$2:$F$1332,MATCH(B2,Master!$C$2:C1007,0)),"NOT IN MASTER SHEET")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C15:D17Cell Valuecontains "LEAVER"textNO
C15:C17Cell Valuebetween 3 and 1000textNO
C13:D14Cell Valuecontains "LEAVER"textNO
C13:C14Cell Valuebetween 3 and 1000textNO
F:FCell Valuecontains "OVERTIME"textNO
G2:G3394Cell Valuecontains "NOT LATE"textNO
A:ACell Valuecontains "NOT IN MASTER SHEET"textNO
3395:1048576,Q15:W18,O3:W14,O15:O18,C2:AA2,P19:W19,A2987:L3394,A2985:A2986,E2985:L2986,A273:L1130,M3:N1130,A1131:N1133,A1134:L2984,M1134:N3394,1:1,O20:W3394,X3:XFD3394,J3:K3394,E13:L17,C3:L12,A2:A272,AC2:XFD2,H3:H3394,C18:L272Cell Valuecontains "LEAVER"textNO
G2:G3394Cell Value>=0.000694444textNO
K2:K3394Cell Value=0textNO
L2:L3394Cell Valuecontains "NOT LATE"textNO
K2:K3394Cell Valuecontains "NOT LATE"textNO
J2:J3394Cell Valuecontains "MANAGER"textNO
I2:I3394Cell Valuecontains "NA"textNO
L2:L3394Expression=L2="First one"textNO
K2:K3394Cell Value=1textNO
L2:L3394Expression=L2="1 Away"textNO
K2:K3394Cell Value=2textNO
L2:L3394Expression=L2="Investigate"textNO


VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim MailAddress As String
Dim MailAddress_CC As String
Dim ByEmp As String
Dim OnDate As String
Dim MinLate As String
Dim NumOffs As String
Dim DueDate As String
On Error Resume Next

If Intersect(Range("L2:L10000"), Target) Is Nothing Or Target.Cells.Count > 1 Then Exit Sub

If IsNumeric(Target.Value) Then

If TextBox1.Text = "Investigate" Then

MailAddress = Range("M" & Target.Row).Value
MailAddress_CC = Range("N" & Target.Row).Value

ByEmp = (Cells(Target.Row, "A"))

OnDate = (Cells(Target.Row, "C"))

MinLate = (Cells(Target.Row, "V"))

NumOffs = (Cells(Target.Row, "K"))

DueDate = (Cells(Target.Row, "X"))

Call Mail_small_Text_Outlook(MailAddress, MailAddress_CC, ByEmp, OnDate, MinLate, NumOffs, DueDate)

' Send the email
emailItem.Send


End If

End If

End Sub
Sub Mail_small_Text_Outlook(MailAddress As String, MailAddress_CC As String, ByEmp As String, OnDate As String, MinLate As String, NumOffs As String, DueDate As String)
Dim xOutApp As Object
Dim xOutMail As Object
Dim cell As Range
Dim strbody As String

Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)

On Error Resume Next
With xOutMail
.To = MailAddress
.Cc = MailAddress_CC
.BCC = ""
.Subject = "Lates Investigation"
.htmlBody = "Hi," & vbNewLine & vbNewLine & "you have a lates investigation to complete on " & ByEmp & " who was late on " & OnDate & " by " & MinLate & " minutes, this is their " & NumOffs & " offence. It is due on " & DueDate & " , please make sure you confirm that you have completed an investigation if necessary."
.Display
End With

On Error GoTo 0

Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
Sub Check_Offences()
Dim MailAddress As String
Dim MailAddress_CC As String
Dim ByEmp As String
Dim OnDate As String
Dim MinLate As String
Dim NumOffs As String
Dim DueDate As String
Dim Lr As Long
Dim r As Long
On Error Resume Next


With Sheets("Lates")

'Determine last row based on data in A
Lr = .Range("A" & .Rows.Count).End(xlUp).Row
'Loop through column K
    For Each cell In .Range("L2:L" & Lr)
     
    
        'test for offences >=3 AND 'email sent' not marked as 'Y' in column W  (Offset 12 from K)
            If UCase(cell) And cell = "Investigate" And Not cell.Offset(0, 12) = "Yes" Then
             'update r as row of interest
                r = cell.Row
                
                'Establish parameters for email sub
                ' email addresses
                MailAddress = .Range("M" & r).Value
                MailAddress_CC = .Range("N" & r).Value
                'Employee
                ByEmp = .Range("A" & r).Value
                'Date
                OnDate = CDate(.Range("C" & r))
                'Minutes late
                MinLate = .Range("V" & r)
                'Number of offences
                NumOffs = .Range("K" & r)
                
                DueDate = .Range("X" & r)
                
                'call email sub and pass variables
                Call Mail_small_Text_Outlook(MailAddress, MailAddress_CC, ByEmp, OnDate, MinLate, NumOffs, DueDate)
                
                 'Send the email
                emailItem.Send
                
                'Mark email for row as sent, with 'Y'  in column W
                .Range("W" & r) = "Yes"
                 
                 End If
    
    Next

End With
End Sub
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Did you read the rule? As I said, you have not broken any rules but (from that rule) it has some good advice ..

We advise you not to 'bump' (reply to) your own posts too quickly after posting ... If you do bump, limit it to no more than once every day.
1.5 hours would be regarded as quite quickly

Since bumped threads have replies, they will no longer appear in the "Unanswered threads" listing, which many members use to look for unanswered questions.
So helpers looking for threads with no replies will skip yours

Remember that your best helper may be asleep on the other side of the world.
.. so be patient.
 
Upvote 0
Did you read the rule? As I said, you have not broken any rules but (from that rule) it has some good advice ..


1.5 hours would be regarded as quite quickly


So helpers looking for threads with no replies will skip yours


.. so be patient.
Apologies, I'm new to vba so I'm just looking for advice
 
Upvote 0
Hi, I have updated the code to the following but am met with the error message (End IF without block IF). Can anyone see where I'm going wrong?

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim MailAddress As String
Dim MailAddress_CC As String
Dim ByEmp As String
Dim OnDate As String
Dim MinLate As String
Dim NumOffs As String
Dim DueDate As String
Dim ActIon As String
On Error Resume Next

If Intersect(Range("K2:K1000"), Target) Is Nothing Or Target.Cells.Count > 1 Then Exit Sub

If IsNumeric(Target.Value) And ActIon = "Investigate"

Else

Exit Sub

MailAddress = Range("M" & Target.Row).Value
MailAddress_CC = Range("N" & Target.Row).Value

ByEmp = (Cells(Target.Row, "A"))

OnDate = (Cells(Target.Row, "C"))

MinLate = (Cells(Target.Row, "V"))

NumOffs = (Cells(Target.Row, "K"))

DueDate = (Cells(Target.Row, "X"))

ActIon = (Cells(Target.Row, "L"))

Call Mail_small_Text_Outlook(MailAddress, MailAddress_CC, ByEmp, OnDate, MinLate, NumOffs, DueDate, ActIon)

' Send the email
emailItem.Send

End If

End If

End Sub
Sub Mail_small_Text_Outlook(MailAddress As String, MailAddress_CC As String, ByEmp As String, OnDate As String, MinLate As String, NumOffs As String, DueDate As String, ActIon As String)
Dim xOutApp As Object
Dim xOutMail As Object
Dim cell As Range
Dim strbody As String

Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)

On Error Resume Next
With xOutMail
.To = MailAddress
.Cc = MailAddress_CC
.BCC = ""
.Subject = "Lates Investigation"
.htmlBody = "Hi," & vbNewLine & vbNewLine & "you have a lates investigation to complete on " & ByEmp & " who was late on " & OnDate & " by " & MinLate & " minutes, this is their " & NumOffs & " offence. It is due on " & DueDate & " , please make sure you confirm that you have completed an investigation if necessary."
.Display
End With

On Error GoTo 0

Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
Sub Check_Offences()
Dim MailAddress As String
Dim MailAddress_CC As String
Dim ByEmp As String
Dim OnDate As String
Dim MinLate As String
Dim NumOffs As String
Dim DueDate As String
Dim ActIon As String
Dim Lr As Long
Dim r As Long
On Error Resume Next


With Sheets("Lates")

'Determine last row based on data in A
Lr = .Range("A" & .Rows.Count).End(xlUp).Row
'Loop through column K
    For Each cell In .Range("K2:K" & Lr)
     
    
        'test for offences >=3 AND 'email sent' not marked as 'Y' in column W  (Offset 12 from K)
            If IsNumeric(cell) And cell >= 3 And Not cell.Offset(0, 12) = "Yes" Then
             'update r as row of interest
                r = cell.Row
                
                'Establish parameters for email sub
                ' email addresses
                MailAddress = .Range("M" & r).Value
                MailAddress_CC = .Range("N" & r).Value
                'Employee
                ByEmp = .Range("A" & r).Value
                'Date
                OnDate = CDate(.Range("C" & r))
                'Minutes late
                MinLate = .Range("V" & r)
                'Number of offences
                NumOffs = .Range("K" & r)
                
                DueDate = .Range("X" & r)
                
                ActIon = .Range("L" & r)
                
                'call email sub and pass variables
                Call Mail_small_Text_Outlook(MailAddress, MailAddress_CC, ByEmp, OnDate, MinLate, NumOffs, DueDate, ActIon)
                
                 'Send the email
                emailItem.Send
                
                'Mark email for row as sent, with 'Y'  in column W
                .Range("W" & r) = "Yes"
                 
                 End If
    
    Next

End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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