I have been searching for an hour to figure this out to no avail.
I am trying to delete rows if the user entered condition matches a cell value but the value to compare it to has leading zeros and therefore doesn't match.
Example:
User enters the value "2", loop through the column on another sheet and if the value is like "2", delete the row. This does not work if the value in the center to check is 002 00 but if they enter 123 and the value is 123 00 it will delete the row. I am even trying using a wildcard but it still wont delete 002 if the entered value is 2.
I have tried wrapping
in Val(), but then it will delete everything containing a 2. For the record,
is shown as a variant/string and the value in the range being compared is a string. The value in the range is alphanumeric, so converting to integer/long would not work.
If I manually change the value from 002 00 to 2 00, it gets deleted correctly. How can I correctly match the two values without modifying the data as it has to keep the format it is in.
I am trying to delete rows if the user entered condition matches a cell value but the value to compare it to has leading zeros and therefore doesn't match.
Example:
User enters the value "2", loop through the column on another sheet and if the value is like "2", delete the row. This does not work if the value in the center to check is 002 00 but if they enter 123 and the value is 123 00 it will delete the row. I am even trying using a wildcard but it still wont delete 002 if the entered value is 2.
Code:
For Each num In RowsToDrop
For i = lastrowC To 7 Step -1
If Report.Range("A" & i).Value Like num & "*" Then
Report.Rows(i).Delete
End If
Next i
Next num
I have tried wrapping
Code:
Report.Range("A" & i).Value
Code:
num
If I manually change the value from 002 00 to 2 00, it gets deleted correctly. How can I correctly match the two values without modifying the data as it has to keep the format it is in.