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 Cannot find "1-1" or "1-1M

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Cannot find "1-1" or "1-1M

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Cannot find "1-1" or "1-1M

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Cannot find "1-1" or "1-1M

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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Cannot find "1-1" or "1-1M

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





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Cannot find "1-1" or "1-1M

Thanks to all for your help. Otto
"Otto Moehrbach" wrote in message
...
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
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
Whats wrong with this? MyWBAccRep.Sheets("Volumes").Cells.Find("latest").Copy.Offset(0, Simon[_2_] Excel Programming 2 August 11th 08 01:29 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM


All times are GMT +1. The time now is 06:38 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"