#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default 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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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)
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"