ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Is there an If Or Then statement? (https://www.excelbanter.com/excel-programming/401720-there-if-then-statement.html)

[email protected]

Is there an If Or Then statement?
 
I'm trying to make this work but I get a Type Mismatch error. Any
clues?

If strFrequency = "ea pay" Or "each pay" Or "Bi Weekly" Or "Bi-Weekly"
Or "BI WEEKLY" Or "BI-WEEKLY" Or "bi weekly" Or "bi-weekly" Or "EA
PAY" Or "EACH PAY" Or "Ea Pay" Or "Each Pay" Then
Range("D11") = lAmount * 2
Else
Range("D11") = lAmount
End If

carlo

Is there an If Or Then statement?
 
2 things

1.) you have to tell excel what you compare everytime

2.) you can use LCase to change the case of all the
Letters in strFrequency to lower case, so you won't
have any problems with case sensitivity.

If LCase(strFrequency) = "ea pay" Or _
LCase(strFrequency) = "each pay" Or _
LCase(strFrequency) = "bi weekly" Or _
LCase(strFrequency) = "bi-weekly" Then
Range("D11") = lAmount * 2
Else
Range("D11") = lAmount
End If

I put the _ after the lines in order to avoid word wrap.
If you want it one whole line, just delete the _ and put
it back together.

hth
Carlo


On Nov 27, 1:00 pm, wrote:
I'm trying to make this work but I get a Type Mismatch error. Any
clues?

If strFrequency = "ea pay" Or "each pay" Or "Bi Weekly" Or "Bi-Weekly"
Or "BI WEEKLY" Or "BI-WEEKLY" Or "bi weekly" Or "bi-weekly" Or "EA
PAY" Or "EACH PAY" Or "Ea Pay" Or "Each Pay" Then
Range("D11") = lAmount * 2
Else
Range("D11") = lAmount
End If




All times are GMT +1. The time now is 03:04 PM.

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