LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 536
Default A simple if < nn then Msgbox "No Match"

Trying to get a message to display if no match is found in this
For Each c In ACM.

I have set FindCable to simply "Donkey" then put an x behind it in the range ACM to test the msgbox alert.

Once I put the code in for the Msgbox it shows "No Match" every time I run the macro, even if Donkey is providing a true match.

What gives?

I have similar examples in my cheat sheet but none have helped me here.

Thanks.
Howard

Option Explicit

Sub PlugedIn()
Dim FindCable As String
Dim ACM As Range
Dim c As Range
Dim lr As Long

With Sheets("Find Cables")

FindCable = "Donkey" 'Range("C3") & " " & Range("C5") & " " & _
Range("C7") & " " & Range("C9") & " " & _
Range("C11") & " " & Range("C13")
End With

lr = Cells(Rows.Count, 6).End(xlUp).Row
Set ACM = Sheets("all cables").Range("F2:F" & lr)

For Each c In ACM

If c = FindCable Then
c.Offset(, -5).Copy
Sheets("Find Cables").Range("A" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues

c.Offset(, -5).Copy
Sheets("Find Cables").Range("B" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues

c.Offset(, -4).Copy
Sheets("Find Cables").Range("C" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues

c.Offset(, -2).Copy
Sheets("Find Cables").Range("D" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues

c.Offset(, 9).Copy
Sheets("Find Cables").Range("E" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues

c.Offset(, 10).Copy
Sheets("Find Cables").Range("F" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues

c.Offset(, 12).Copy
Sheets("Find Cables").Range("G" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues

ElseIf c < FindCable Then
MsgBox "No Match"
Exit Sub
End If

Next
End Sub
 
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
MsgBox "Choose one ", vbYesNoCancel, " Three Options. " Steved Excel Programming 3 March 11th 09 08:27 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
How to replace "#N/A" w "0"when vlookup couldn't find the match? Holly Excel Discussion (Misc queries) 2 July 17th 06 11:48 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


All times are GMT +1. The time now is 01:41 AM.

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"