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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
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,461
Messages
6,124,954
Members
449,198
Latest member
MhammadishaqKhan

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