First post - How do you build If statement condition dynamically

Joined
Oct 13, 2008
Messages
2
Reaction score
0
Hello,
This is my first post and hope this is not a silly question.

Is it possible to create a criteria for an if or case statement dynamically?

For example, if the string variable 'criteria' is literally "Sheet1.Cells.Range(A1).value = "A" AND Sheet1.Cells.Range(B1) <> "B", I would like to put:


Option #1:
If criteria then
Sheet1.Rows.EntireRow.Delete
End if

result: Type mismatch error

Option #2:
use a case statement?

Select Case criteria
Case criteria
MsgBox ("deleting...")
Sheet1.Rows.EntireRow.Delete
Case Else
MsgBox ("Row not deleted.")
End Select

result: deletes row regardless of criteria being passed

Thanks in advance.
 
Joined
Oct 13, 2008
Messages
2
Reaction score
0
I would like to add that the result described in prev post means the actual result I am getting instead of my desired result of Excel deleting the row based on the criteria string passed
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top