ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help needed nested conditional formula (https://www.excelbanter.com/excel-programming/430432-help-needed-re-nested-conditional-formula.html)

gcotterl[_2_]

Help needed nested conditional formula
 
If M6 contains "J" or "L"
if the third character in M6 is a "-"
I want S6 to contain ""X"
else, I want S6 to contain "Y"
else, I want S6 to contain "Z".

How do I write the formula?

smartin

Help needed nested conditional formula
 
gcotterl wrote:
If M6 contains "J" or "L"
if the third character in M6 is a "-"
I want S6 to contain ""X"
else, I want S6 to contain "Y"
else, I want S6 to contain "Z".

How do I write the formula?



Option Explicit

Sub gcotterl()
Dim Check As String
Check = Range("M6").Value
If InStr(1, Check, "J") + InStr(1, Check, "L") 0 Then
If Mid(Check, 3, 1) = "-" Then
Range("S6").Value = "X"
Else
Range("S6").Value = "Y"
End If
Else
Range("S6").Value = "Z"
End If
End Sub


All times are GMT +1. The time now is 10:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com