Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Counting text numbers

Excel XP & Win XP
I have a range of cells, all formatted as text. The user will enter numbers
into those cells, one at a time. I want to trap the instance where the user
will enter the same number twice into this range of cells. I am using the
VBA line:
If Application.CountIf(TheRng, Target.Value) 1 Then....
to trap the repeating number.
The problem is that the user may enter "8" in one cell and "08" in another.
In this instance, the above line of code will count this as 2 entries of the
same number. Because these cells are formatted as text, "8" and "08" are
not the same and should not be counted as a repeating entry.
How can I write the code so that VBA does not consider "8" and "08" as the
same? Thanks for your time. Otto


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default Counting text numbers

Convert them both to integers in code, if 8 is in A1 and 08 in A2 then
MsgBox CInt(Cells(1, 1)) = CInt(Cells(2, 1))


--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Otto Moehrbach" wrote:

Excel XP & Win XP
I have a range of cells, all formatted as text. The user will enter numbers
into those cells, one at a time. I want to trap the instance where the user
will enter the same number twice into this range of cells. I am using the
VBA line:
If Application.CountIf(TheRng, Target.Value) 1 Then....
to trap the repeating number.
The problem is that the user may enter "8" in one cell and "08" in another.
In this instance, the above line of code will count this as 2 entries of the
same number. Because these cells are formatted as text, "8" and "08" are
not the same and should not be counted as a repeating entry.
How can I write the code so that VBA does not consider "8" and "08" as the
same? Thanks for your time. Otto



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Counting text numbers

John
If both are converted to integers, then they will be the same. My
problem is that my code is seeing them as being the same now. I want the
code to see them as being different. Thanks for your time. Otto
"John Bundy" (remove) wrote in message
...
Convert them both to integers in code, if 8 is in A1 and 08 in A2 then
MsgBox CInt(Cells(1, 1)) = CInt(Cells(2, 1))


--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Otto Moehrbach" wrote:

Excel XP & Win XP
I have a range of cells, all formatted as text. The user will enter
numbers
into those cells, one at a time. I want to trap the instance where the
user
will enter the same number twice into this range of cells. I am using
the
VBA line:
If Application.CountIf(TheRng, Target.Value) 1 Then....
to trap the repeating number.
The problem is that the user may enter "8" in one cell and "08" in
another.
In this instance, the above line of code will count this as 2 entries of
the
same number. Because these cells are formatted as text, "8" and "08" are
not the same and should not be counted as a repeating entry.
How can I write the code so that VBA does not consider "8" and "08" as
the
same? Thanks for your time. Otto





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
Counting a series of text and/or numbers within columns andrew Excel Discussion (Misc queries) 17 June 25th 08 09:49 AM
Counting up with numbers and text pwalters Excel Worksheet Functions 7 June 20th 07 08:59 AM
Counting rows containing data (both numbers and text) mconnolly Excel Worksheet Functions 4 August 29th 05 03:58 PM
Counting NUMBERS &/or TEXT from a column to other sheet ? Trixie Excel Worksheet Functions 4 March 3rd 05 07:59 PM
Counting Numbers with Text scottymelloty Excel Worksheet Functions 6 November 22nd 04 08:31 PM


All times are GMT +1. The time now is 08:50 AM.

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"