ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Value LIKE (https://www.excelbanter.com/excel-programming/416814-value-like.html)

Pyrite

Value LIKE
 
Hi,

I'm trying to write a line of code to test a value that has been input for
containing a :

I was thinking something similar to:

If Target.Value Like "##:##" Then

However, the like will not recognise Target.Value and as such would only
look for that eact line being entered. Any suggestions? It is to work on a
Workbook Change and basically will be If the string contains a : then Exit Sub

JLGWhiz

Value LIKE
 
Maybe: If ActiveCell.Value Like "*:*"

"Pyrite" wrote:

Hi,

I'm trying to write a line of code to test a value that has been input for
containing a :

I was thinking something similar to:

If Target.Value Like "##:##" Then

However, the like will not recognise Target.Value and as such would only
look for that eact line being entered. Any suggestions? It is to work on a
Workbook Change and basically will be If the string contains a : then Exit Sub


Kent Prokopy

Value LIKE
 
If Target.Value Like "*:*" Then Exit Sub

"Pyrite" wrote:

Hi,

I'm trying to write a line of code to test a value that has been input for
containing a :

I was thinking something similar to:

If Target.Value Like "##:##" Then

However, the like will not recognise Target.Value and as such would only
look for that eact line being entered. Any suggestions? It is to work on a
Workbook Change and basically will be If the string contains a : then Exit Sub


Mike H

Value LIKE
 
Try this

If activecell.Value Like "*:*" Then

Note this won't find a colon in a formula or in a time format

Mike

"Pyrite" wrote:

Hi,

I'm trying to write a line of code to test a value that has been input for
containing a :

I was thinking something similar to:

If Target.Value Like "##:##" Then

However, the like will not recognise Target.Value and as such would only
look for that eact line being entered. Any suggestions? It is to work on a
Workbook Change and basically will be If the string contains a : then Exit Sub


Pyrite

Value LIKE
 
Thank you all for your help.

Good Afternoon Mike, I wasnt being impatient by the way, I am in the UK and
have been trying to think of ways around my problem for hours htis morning. I
did update our conversation from yesterday as I am still having the same
problems and was hoping for a response from a UK user so I could at least try
adding another If The Exit Sub to try and get around my : problem that way.
As you rightly state it wont tork for the time format.

I think it may be time to throw in the towel. This problem appears almost
unsolvable, I have tried at least 5 different sets of code as well as
countless alterations made by me (somewhat ham fistedly no doubt) but none
the less I just cannot see there being a solution.

Thank you for the time you have given to trying to help me find the
solution. Alas I fear I may have to use On Error resume Next or change the
error message to offer instruction to the user. It just will not stop giving
an error when I enter the time with : inclusive.
Thanks again

"Mike H" wrote:

Try this

If activecell.Value Like "*:*" Then

Note this won't find a colon in a formula or in a time format

Mike

"Pyrite" wrote:

Hi,

I'm trying to write a line of code to test a value that has been input for
containing a :

I was thinking something similar to:

If Target.Value Like "##:##" Then

However, the like will not recognise Target.Value and as such would only
look for that eact line being entered. Any suggestions? It is to work on a
Workbook Change and basically will be If the string contains a : then Exit Sub


Rick Rothstein

Value LIKE
 
If activecell.Value Like "*:*" Then

Note this won't find a colon in a formula or in a time format


There is always these methods for those...

To operate on a formula
==========================
If ActiveCell.Formula Like "*:*" Then

To operate on a formatted value like a time format
================================================== ==
If ActiveCell.Text Like "*:*" Then

--
Rick (MVP - Excel)

MikeP125

Value LIKE
 
I had the exact same situation with a different string and I could NOT figure
it out! This works perfectly!! THANK YOU!!

"Mike H" wrote:

Try this

If activecell.Value Like "*:*" Then

Note this won't find a colon in a formula or in a time format

Mike

"Pyrite" wrote:

Hi,

I'm trying to write a line of code to test a value that has been input for
containing a :

I was thinking something similar to:

If Target.Value Like "##:##" Then

However, the like will not recognise Target.Value and as such would only
look for that eact line being entered. Any suggestions? It is to work on a
Workbook Change and basically will be If the string contains a : then Exit Sub



All times are GMT +1. The time now is 09:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com