ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Search and find (https://www.excelbanter.com/excel-programming/274883-search-find.html)

Rick K

Search and find
 
Need help on creating a routine that loops down through a
spreadsheet's rows that contain entries and compares the
entry in column 1 (State abrevation) with column 2 entry
(shipment method). Specificly I want to return a msgbox to
the user when the state = "HI" or "AK" and the ship method
is "ground", and then quits the vba form so the user can
correct the situation.
Thnaks

Dave Peterson[_3_]

Search and find
 
Something like this:

Option Explicit
Sub testme()

Dim myCell As Range
Dim myRng As Range

With Worksheets("sheet1")
Set myRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))
End With

For Each myCell In myRng.Cells
With myCell
Select Case LCase(.Value)
Case "ak", "hi"
.Select
MsgBox "error on row: " & .Row
Exit Sub
Case Else
'do nothing
End Select
End With
Next myCell

End Sub

(not sure how you're userform works, though.)

Couldn't they just take the interstate to hi?



Rick K wrote:

Need help on creating a routine that loops down through a
spreadsheet's rows that contain entries and compares the
entry in column 1 (State abrevation) with column 2 entry
(shipment method). Specificly I want to return a msgbox to
the user when the state = "HI" or "AK" and the ship method
is "ground", and then quits the vba form so the user can
correct the situation.
Thnaks


--

Dave Peterson



All times are GMT +1. The time now is 11:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com