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.
 

Some videos you may like

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Steeviee

Active Member
Joined
Sep 9, 2009
Messages
380
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.
 

krishhi

Active Member
Joined
Sep 8, 2008
Messages
328
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
 

Watch MrExcel Video

Forum statistics

Threads
1,123,304
Messages
5,600,858
Members
414,408
Latest member
macroSmith

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
Top