Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88050

use whereclause within a if condition

$
0
0

I have 5 string parameter A,B,C,D,E, and I want to use them as a condition in a IF statement.

I also have 5 local variable, to match the parameters

The problem is, I don't know whether any of them is empty string. If it is empty string , I don't want them to be use in the if condition

Private Function XX(A As String, B As String, C As String, D As String, E As String) As Long

Dim AA As String
Dim BB As String
Dim CC As String
Dim DD As String
Dim EE As String

If A = AA && B = BB && C = CC & D = DD & E = EE Then
.....
End If

I know a whereclause in sql can do it, like:

Dim Whereclause As String
IF B is NULL Then
whereclause = " WHERE AA = " + A + "AND C = " + C + "AND D = " + 
D ....

But seems I can't put it into an IF statement, as the query itself is a string.

Is there anyways to use in the IF condition? I don't need to connect DB, just want to check records in a excel sheet with the rows matching all the parameter

Thanks very much for helping~~


Viewing all articles
Browse latest Browse all 88050

Trending Articles