PC Review


Reply
Thread Tools Rate Thread

Cannot find "1-1" or "1-1M

 
 
Otto Moehrbach
Guest
Posts: n/a
 
      17th Feb 2009
Excel XP & Win XP

This one has me stumped. I have a column consisting of various number
combinations including:

1-1

1-1M

My code is in a For loop running down the column:

If i = "1-1" Or i = "1-1M" Then

The 1-1 has an apostrophe in front of it to preclude Excel seeing it as a
date. I checked the length of each with LEN and they are 3 and 4.

The above code cannot find/see the 1-1 or the 1-1M.

I even wrote the code as CStr(i)= and had no luck.

I am open to any suggestions. Thanks for your time. Otto


 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      17th Feb 2009
Make sure the letter M is capitalized. This code worked for me with 1-1 in
cell A1 and 1-M in cell A2

For RowCount = 1 To 2
MsgBox (Range("A" & RowCount))
If Range("A" & RowCount) = "1-1" Then
MsgBox ("Found ""1-1""")
End If
If Range("A" & RowCount) = "1-1M" Then
MsgBox ("Found 1-1M")
End If
Next RowCount


"Otto Moehrbach" wrote:

> Excel XP & Win XP
>
> This one has me stumped. I have a column consisting of various number
> combinations including:
>
> 1-1
>
> 1-1M
>
> My code is in a For loop running down the column:
>
> If i = "1-1" Or i = "1-1M" Then
>
> The 1-1 has an apostrophe in front of it to preclude Excel seeing it as a
> date. I checked the length of each with LEN and they are 3 and 4.
>
> The above code cannot find/see the 1-1 or the 1-1M.
>
> I even wrote the code as CStr(i)= and had no luck.
>
> I am open to any suggestions. Thanks for your time. Otto
>
>
>

 
Reply With Quote
 
egun
Guest
Posts: n/a
 
      17th Feb 2009
Does it help if you use i.Text instead of just i? I assume that "i" is a
reference to a cell out of a "for each i in myRange.cells" loop?

Eric

 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      17th Feb 2009
Maybe

For i = 1 To 100
If Range("A" & i) = "1-1" Then
MsgBox ("1-1 in row ") & i
ElseIf UCase(Range("A" & i)) = "1-1M" Then
MsgBox ("1-1M in row ") & i
End If
Next i

Mike

"Otto Moehrbach" wrote:

> Excel XP & Win XP
>
> This one has me stumped. I have a column consisting of various number
> combinations including:
>
> 1-1
>
> 1-1M
>
> My code is in a For loop running down the column:
>
> If i = "1-1" Or i = "1-1M" Then
>
> The 1-1 has an apostrophe in front of it to preclude Excel seeing it as a
> date. I checked the length of each with LEN and they are 3 and 4.
>
> The above code cannot find/see the 1-1 or the 1-1M.
>
> I even wrote the code as CStr(i)= and had no luck.
>
> I am open to any suggestions. Thanks for your time. Otto
>
>
>

 
Reply With Quote
 
exceluserforeman
Guest
Posts: n/a
 
      19th Feb 2009
Public Sub OttoMan()
Dim strA, strM, strCell As String
Dim i As Integer
strA = UCase("1-1")
strM = UCase("1-1m")

Range("A1").Select
For i = 0 To 100
strCell = UCase(ActiveCell.Offset(i, 0).Text)
If strA = strCell Then
ActiveCell.Offset(i, 1).Value = "strA"
End If

If strCell = strM Then
ActiveCell.Offset(i, 1).Value = "strM"
End If
strCell = ""
Next
End Sub

"Otto Moehrbach" wrote:

> Excel XP & Win XP
>
> This one has me stumped. I have a column consisting of various number
> combinations including:
>
> 1-1
>
> 1-1M
>
> My code is in a For loop running down the column:
>
> If i = "1-1" Or i = "1-1M" Then
>
> The 1-1 has an apostrophe in front of it to preclude Excel seeing it as a
> date. I checked the length of each with LEN and they are 3 and 4.
>
> The above code cannot find/see the 1-1 or the 1-1M.
>
> I even wrote the code as CStr(i)= and had no luck.
>
> I am open to any suggestions. Thanks for your time. Otto
>
>
>

 
Reply With Quote
 
Otto Moehrbach
Guest
Posts: n/a
 
      19th Feb 2009
Thanks to all for your help. Otto
"Otto Moehrbach" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Excel XP & Win XP
>
> This one has me stumped. I have a column consisting of various number
> combinations including:
>
> 1-1
>
> 1-1M
>
> My code is in a For loop running down the column:
>
> If i = "1-1" Or i = "1-1M" Then
>
> The 1-1 has an apostrophe in front of it to preclude Excel seeing it as a
> date. I checked the length of each with LEN and they are 3 and 4.
>
> The above code cannot find/see the 1-1 or the 1-1M.
>
> I even wrote the code as CStr(i)= and had no luck.
>
> I am open to any suggestions. Thanks for your time. Otto
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP!!! "find now" is changing my view from "day/week/month" to"Active Appointments" johng34 Microsoft Outlook Calendar 1 12th Jun 2009 03:31 AM
Field Names: "LongName", "ShortName", "Code", "Description","Comments" PeteCresswell Microsoft Access 2 25th Feb 2009 11:41 PM
HELP on "left","right","find","len","substitute" functions serene83 Microsoft Excel Misc 5 27th Jun 2006 02:23 AM
<FORM METHOD="post" onSubmit="return fieldcheck()" name="orientation" action="http://ws-kitty.BU.edu/AT/survey/orientation/script/write.asp" language="JavaScript"> Joeyej Microsoft ASP .NET 0 4th Jun 2004 08:55 PM
When doing a "Find" in a form, would like the "Match" to default to "Any Part of Field" =?Utf-8?B?RG9u?= Microsoft Access Forms 2 25th Oct 2003 04:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:39 AM.