Simple MSG BOX Help

vinothsudar

Board Regular
Joined
Jun 10, 2009
Messages
171
Hi all,

I have values in Column D : D 20,000.

This column values shold be " Chennai or Delhi or Madurai"

If data not found i need a msgbox "Invalid City"

Please help on that.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Can you use another column?

Say E1=if(or(D1="Chenai",D1="Dehli",D1="Madurai")=true,"","Invalid City")
Then copy down all of your data and this will highlight the problematic rows (You could filter on this also.
 
Upvote 0
hey look at the following code

Code:
Sub validate()

Dim i As Integer, j As Integer, s As String
Dim lr As Integer
lr = ActiveSheet.UsedRange.Rows.Count
For i = 1 To lr
    s = Range("D" & i).Value
    If s <> "chennai" And s <> "madhurai" And s <> "delhi" Then
    Range("E" & i).Value = s
   
    End If
    Next

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,039
Messages
6,122,802
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top