Solved

Message Box keeps on popping up

Posted on 2010-11-24
5
377 Views
Last Modified: 2012-06-21
Hello,  

I have included in my VBA a line that reads:  
MsgBox "Available from 1 to 150 MHz"
whenever there is an frequency entry (column M) in that is lower than 1 or higher than 150.  

However, the message box just keeps on popping up, even when the frequency section is empty.  You will see what I mean when you click on the drop down list in the attached file.  

I even added a case: Not IsEmpty (Cell M).  Please tell me how I can fix this bug.  

Thanks,
Juju
OppLog.xlsm
0
Comment
Question by:JuJuChia
  • 2
  • 2
5 Comments
 
LVL 50

Expert Comment

by:Dave Brett
ID: 34210691
You could try this approach.

test it being between 1 and 150. if so do nothing

if not, test for blank
if blank do nothing
else delete (say for 200, or 0.5 etc)  and provide the message

Cheers

Dave
Case 1 < Range("M" & x).Value < 150
        Case Else
            If Not IsEmpty(Range("M" & x).Value) Then
                Range("M" & x).Value = ""
                MsgBox "Available from 1 to 150 MHz"
            End If
            'Limited frequency range for P4 (1 to 150 MHz)
        End Select

Open in new window

0
 
LVL 59

Expert Comment

by:Saurabh Singh Teotia
ID: 34210707
There you go use this...

Saurabh..
OppLog.xlsm
0
 

Author Comment

by:JuJuChia
ID: 34210856
Hi Brettdj and Saurabh,

I have tried following your approach, but when testing (type in 100), the message box came up.  Did I misunderstand your code?  


Thanks,
Juju
OppLog.xlsm
0
 
LVL 50

Accepted Solution

by:
Dave Brett earned 500 total points
ID: 34211002
Not my best day

pls try amended version
Select Case Range("M" & x).Value
        Case 1 To 150
        Case Else
            If Not IsEmpty(Range("M" & x).Value) Then
                Range("M" & x).Value = ""
                MsgBox "Available from 1 to 150 MHz"
            End If
    End Select

Open in new window

0
 

Author Closing Comment

by:JuJuChia
ID: 34211119
Thanks, Brettdj.
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question