I want to copy the contents of a cell only if the cell conta开发者_运维技巧ins times in the following format: 9:00-5:00pm. (The cell may contain abbreviations such as "N/A", "RDO", "Leave" etc. I tried this:
If Worksheets(2).Cells(R, c).Value Like "*-*" Then
Worksheets(26).Cells(x, c).Value = Worksheets(2).Cells(R, c).Value
end if
but it doesn't work properly. I'm experience with VBA in Excel, but I've never used the LIKE operator before.
To look for a -
only;
"*-*"
Alternatively you could be stricter;
if x like "#*:##-#*:##[ap]m"
the Like
part of your code is fine. to prove it, run this code fragment:
If "9:00-5:00pm" Like "*-*" Then
MsgBox "True"
End If
the problem must lie elsewhere. post some details of how it doesn't work for you...
精彩评论