Dear Great Minds of Excel,
Is it possible to use a variable to represent an operator. For example, in an if then statement I want the operator to be able to be changed based on a users input. Can I replace >= with Oprtr after defining Oprtr as ">="?
Is this possible in vba?
Thanks for any assistance on this.
/s/
Craig
Is it possible to use a variable to represent an operator. For example, in an if then statement I want the operator to be able to be changed based on a users input. Can I replace >= with Oprtr after defining Oprtr as ">="?
Code:
Dim Oprtr
OprtrA = ">="
OprtrB = "<="
oRow = 1
oCol = 4
'In the following formula I want to replace the >= with the variable Oprtr
If ws.Cells(oRow, oCol).Offset(0, 0) > "" And Format(ws.Cells(oRow, oCol).Offset(0, dte), "yyyy/mm/dd") >= Format(tbxVehicleDateFrom, "yyyy/mm/dd") And Format(ws.Cells(oRow, oCol).Offset(0, dte), "yyyy/mm/dd") <= Format(tbxVehicleDateTo, "yyyy/mm/dd") Then
'The new formula would be:
If ws.Cells(oRow, oCol).Offset(0, 0) > "" And Format(ws.Cells(oRow, oCol).Offset(0, dte), "yyyy/mm/dd") [B][COLOR=#FF0000]OprtrA[/COLOR][/B] Format(tbxVehicleDateFrom, "yyyy/mm/dd") And Format(ws.Cells(oRow, oCol).Offset(0, dte), "yyyy/mm/dd") [B][COLOR=#FF0000]OprtrB[/COLOR][/B] Format(tbxVehicleDateTo, "yyyy/mm/dd") Then
Is this possible in vba?
Thanks for any assistance on this.
/s/
Craig