If a Cell within a range contains "Text" then msgbox

emmhor

New Member
Joined
Jun 14, 2017
Messages
17
Hi all,

I got a worksheet with many combo boxes they're linked to a cell and what my idea is to provide a prompt if one of the cell within the range contain text which is not allowed.
So i got combo box S1-S29
The selection user can click within that combo box is : Kies,1,2,3,4,5
So I tried the following,

Code based on, range, if cell cointains "kies" then msgbox.
This work with single cells but not when used in a range.

I tried multiple codes but I bumped into issues where each cell is checked 1 by 1 but only 1 needs to be correct to bypass the msgbox.
It is hard to explain since I don't got the code anymore.

So could anyone write me a sub regarding my question.
Comboxboxes name convention s1-s29
Linked to cell s1-s29 so result of ^^ will be visible in the cells corresponding to the combobox name3

What I want is that a msgbox apear when a cell within the range s1-s29 has the word "kies" or isEmpty.
And a code that scrolls through all the cells 1 by 1 not all at once.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi, how about something like this:

Code:
If Application.CountIf(Range("S1:S29"), "kies") Or Application.CountBlank(Range("S1:S29")) Then
    MsgBox "Not all cells complete"
    Exit Sub
End If
 
Upvote 0
Hey and thank you for your reply,

This did seem to work when I use numbers. but with the work "kies"it didn't seem to work.
Im always getting the prompt"not all cells complete"

But for this is enough thanks allot +1

Hi, how about something like this:

Code:
If Application.CountIf(Range("S1:S29"), "kies") Or Application.CountBlank(Range("S1:S29")) Then
    MsgBox "Not all cells complete"
    Exit Sub
End If
 
Last edited:
Upvote 0
This did seem to work when I use numbers. but with the work "kies"it didn't seem to work.
Im always getting the prompt"not all cells complete"

Hi, I thought you wanted the message box to appear if any of the cells contained the word "kies" - is that not the case?
 
Upvote 0
Ow haha no it's not like that.
I use combo boxes to give out a score per subject a score from Kies,and then 1-5.
And It is very important that all fields have a score so a value Kies, or no number IS NOT ALLOWED.

So msgbox on "Kies" or a number

Hi, I thought you wanted the message box to appear if any of the cells contained the word "kies" - is that not the case?
 
Upvote 0
I'm even more confused now! In plain English - what are the conditions that should trigger the message box?
 
Upvote 0
If Cell S1-S28 cointain the text "kies" or isEmpty so no number/letter then msgbox "XxxxxX"

Hi, that is what the code does - are you sure that all the cells are populated and none have "kies"? Is the sheet where this test needs to happen active when you run the code?
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,157
Members
453,021
Latest member
Justyna P

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