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.
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.