Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 423
  • Last Modified:

Message Box keeps on popping up

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
JuJuChia
Asked:
JuJuChia
  • 2
  • 2
1 Solution
 
Dave BrettCommented:
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
 
Saurabh Singh TeotiaCommented:
There you go use this...

Saurabh..
OppLog.xlsm
0
 
JuJuChiaAuthor Commented:
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
 
Dave BrettCommented:
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
 
JuJuChiaAuthor Commented:
Thanks, Brettdj.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now