Solved

Message Box keeps on popping up

Posted on 2010-11-24
5
334 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
Comment Utility
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
Comment Utility
There you go use this...

Saurabh..
OppLog.xlsm
0
 

Author Comment

by:JuJuChia
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks, Brettdj.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
Outlook Free & Paid Tools
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now