Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default How can Excel check that a text string is even-numbered or not?

I've been searching the archives but don't even know where to begin
because I don't know what function would be used in Excel to do this.
After some time, it just occurred to me that even conditional
formatting would work. An odd number of characters (I have code to
remove punctuation and spaces that I'd run on the text string first),
would make the cell turn red and even number of characters would turn
the cell background green because I need even-numbered text strings
and this would test for that before I go further.

I know something can be done because of this one message I managed to
find:
http://groups.google.ca/group/micros...a1f0de1cf496d2
but that's all there seems to be as Excel users are usu. concerned
with odd- and even-numbered rows rather than the length of a string of
text. tia! :oD
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default How can Excel check that a text string is even-numbered or not?

On Fri, 06 Apr 2007 18:01:06 -0400, StargateFan
wrote:

I've been searching the archives but don't even know where to begin
because I don't know what function would be used in Excel to do this.
After some time, it just occurred to me that even conditional
formatting would work. An odd number of characters (I have code to
remove punctuation and spaces that I'd run on the text string first),
would make the cell turn red and even number of characters would turn
the cell background green because I need even-numbered text strings
and this would test for that before I go further.

I know something can be done because of this one message I managed to
find:
http://groups.google.ca/group/micros...a1f0de1cf496d2
but that's all there seems to be as Excel users are usu. concerned
with odd- and even-numbered rows rather than the length of a string of
text. tia! :oD


p.s., it wouldn't have to necessarily be conditional formatting, nor
would it have to be changing the cell background colour, btw. That
was just a thought. Anything that indicates when a text string is an
even number of characters in length would be fine.

(Also, the example in the URL above deals with a macro. Hoping I
didn't confuse the issue with that.)

Thanks! :oD

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default How can Excel check that a text string is even-numbered or not?

Everything gets counted, including spaces and it requires
the Analysis TookPak be enabled in Tools | Add-ins...
=ISEVEN(LEN(B3))
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"StargateFan"

wrote in message
On Fri, 06 Apr 2007 18:01:06 -0400, StargateFan
wrote:

p.s., it wouldn't have to necessarily be conditional formatting, nor
would it have to be changing the cell background colour, btw. That
was just a thought. Anything that indicates when a text string is an
even number of characters in length would be fine.

(Also, the example in the URL above deals with a macro. Hoping I
didn't confuse the issue with that.)
Thanks! :oD

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default How can Excel check that a text string is even-numbered or not?

On Fri, 6 Apr 2007 15:24:57 -0700, "Jim Cone"
wrote:

Everything gets counted, including spaces and it requires
the Analysis TookPak be enabled in Tools | Add-ins...
=ISEVEN(LEN(B3))


Any way to do this without an addin?? Thanks.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default How can Excel check that a text string is even-numbered or not?

Hi StargateFen,

Alternatively, without the ATp addin, the formula:

=MOD(LEN(A1),2)=0

will return True or False or even and odd length strings.

If you wish to use Conduitional formatting, use the above
formala for one conditiona and use the following formula
for a second condition:

=MOD(LEN(A1),2)=1 (odd)


---
Regards,
Norman


"StargateFan" wrote in message
...
On Fri, 06 Apr 2007 18:01:06 -0400, StargateFan
wrote:

I've been searching the archives but don't even know where to begin
because I don't know what function would be used in Excel to do this.
After some time, it just occurred to me that even conditional
formatting would work. An odd number of characters (I have code to
remove punctuation and spaces that I'd run on the text string first),
would make the cell turn red and even number of characters would turn
the cell background green because I need even-numbered text strings
and this would test for that before I go further.

I know something can be done because of this one message I managed to
find:
http://groups.google.ca/group/micros...a1f0de1cf496d2
but that's all there seems to be as Excel users are usu. concerned
with odd- and even-numbered rows rather than the length of a string of
text. tia! :oD


p.s., it wouldn't have to necessarily be conditional formatting, nor
would it have to be changing the cell background colour, btw. That
was just a thought. Anything that indicates when a text string is an
even number of characters in length would be fine.

(Also, the example in the URL above deals with a macro. Hoping I
didn't confuse the issue with that.)

Thanks! :oD





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default How can Excel check that a text string is even-numbered or not?

will return True or False or even and odd length strings.

Should read:

will return True or False for even and odd length strings.



---
Regards,
Norman


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default How can Excel check that a text string is even-numbered or not?


=MOD(LEN(B3),2)=0
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware

"StargateFan"

wrote in message
On Fri, 6 Apr 2007 15:24:57 -0700, "Jim Cone"
wrote:

Any way to do this without an addin?? Thanks.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default How can Excel check that a text string is even-numbered or not?

On Fri, 6 Apr 2007 23:39:41 +0100, "Norman Jones"
wrote:

Hi StargateFen,

Alternatively, without the ATp addin, the formula:

=MOD(LEN(A1),2)=0

will return True or False or even and odd length strings.

If you wish to use Conduitional formatting, use the above
formala for one conditiona and use the following formula
for a second condition:

=MOD(LEN(A1),2)=1 (odd)


[snip]

This works a treat. I'm in process of completing first job using this
spreadsheet. But I ran into a finetuning question.

Can we add text to the conditional formatting somehow? The archives
don't yield anything. What I was thinking is something like this as
an idea:


=MOD(LEN(A1),2)=0"text: This works. You can use."
=MOD(LEN(A1),2)=1"text: This is odd-numbered and won't work. Find
something else."

I just chose silly messages but I hope purpose is understood, that the
user is actually notified whether something will work or not. Thanks!
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default How can Excel check that a text string is even-numbered or not?

Hi StargateFan,

'-------------------
This works a treat. I'm in process of completing first job using this
spreadsheet. But I ran into a finetuning question.

Can we add text to the conditional formatting somehow? The archives
don't yield anything. What I was thinking is something like this as
an idea:


=MOD(LEN(A1),2)=0"text: This works. You can use."
=MOD(LEN(A1),2)=1"text: This is odd-numbered and won't work. Find
something else."

I just chose silly messages but I hope purpose is understood, that the
user is actually notified whether something will work or not. Thanks!
'-------------------

I do not think that you can use Conditional Formatting to
return a message.

I no nothing of your application, but perhaps you could use
the Worksheet_Change event to report the problematic string?

Perhaps, try something like:

'=============
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range
Dim Rng2 As Range
Dim rCell As Range
Dim CMT As Comment

Set Rng = Me.Range("A1:A100") '<<==== CHANGE
Set Rng2 = Intersect(Rng, Target)

If Not Rng2 Is Nothing Then
For Each rCell In Rng2.Cells
With rCell
On Error Resume Next
.Comment.Delete
On Error GoTo 0
If Len(.Value) Mod 2 = 1 Then
Set CMT = .AddComment
With CMT
.Text "This is odd-numbered and won't work." _
& vbLf & " Find something else."
.Visible = True
End With
End If
End With
Next rCell
End If

End Sub
'<<=============

This is worksheet event code and should be pasted into
the worksheets's code module (not a standard module
and not the workbook's ThisWorkbook module):

Right-click the worksheet's tab
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.


---
Regards,
Norman


  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default How can Excel check that a text string is even-numbered or not?


I no nothing of your application, but perhaps you could use


I know nothing of your application, but perhaps you could use


---
Regards,
Norman




  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default How can Excel check that a text string is even-numbered or not?

On Sun, 8 Apr 2007 12:13:53 +0100, "Norman Jones"
wrote:

Hi StargateFan,

'-------------------
This works a treat. I'm in process of completing first job using this
spreadsheet. But I ran into a finetuning question.

Can we add text to the conditional formatting somehow? The archives
don't yield anything. What I was thinking is something like this as
an idea:


=MOD(LEN(A1),2)=0"text: This works. You can use."
=MOD(LEN(A1),2)=1"text: This is odd-numbered and won't work. Find
something else."

I just chose silly messages but I hope purpose is understood, that the
user is actually notified whether something will work or not. Thanks!
'-------------------

I do not think that you can use Conditional Formatting to
return a message.


[snip]

Okay. Understood. I didn't think there was a way but what do I know?
<g

I did try putting a "checker" cell elsewhere in the sheet since only
one row and two columns are actively used in this sheet. It almost
works except I can't figure out how to "hide" the text that isn't
needed. I duplicated the above conditions except making the A1
absolute ($A$1) while keeping the same colours and text attributes in
the text that comes up in these other cells as A1. The difference is
that there is text revealed. One cell says:

"This text is not even-numbered, You cannot use it for a syllacrostic
puzzle."

and the other says:

"This text WORKS!! You can use it for a syllacrostic!"

The only problem I've run into is the condition of completely hiding
one cell when the other is valid. Both of them show up except that
one is formatted when the other isn't.

Both disappear when the cell is blank, however.

I think this will work. Since there are only 2 conditions needed for
these additional 2 cells, that leaves a third one free to see if I can
hide one text over the other. It might even be as easy as depending
on the colour of the other cell, maybe, since that changes. More
research in the archives ... <g

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check for NON-presence of a string in another string G.P.N.L. c.v.a. Excel Worksheet Functions 4 December 11th 09 06:10 PM
Change 3 letter text string to a number string Pete Excel Discussion (Misc queries) 3 December 31st 07 07:47 PM
create numbered sortable numbered list in excel coloradio Excel Discussion (Misc queries) 2 November 15th 06 06:50 PM
Excel VBA - Check/Format String magix Excel Discussion (Misc queries) 1 November 6th 05 11:02 AM
check if the text string start with a specific character September21 New Users to Excel 5 September 22nd 05 03:07 PM


All times are GMT +1. The time now is 02:01 PM.

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

About Us

"It's about Microsoft Excel"