Solved

Command Button

Posted on 2002-03-29
4
141 Views
Last Modified: 2010-05-02
I need to find a way to active a message box based on several variables

First is ActiveCell.Offset (0,-31) value is between 0255-0258 or 0555-0559 or 0855-0859, or 1155-1159 or 1455-1459 or 1755-1759, or 2055-2059, or 2355-2359.  And if ActiveCell.Offset (0,-35) is blank.  Then activate Message Box "Please enter the data"
0
Comment
Question by:sandramac
4 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 6904736
Hi sandramac,

Better ask al these excel questions in the Office section but here we go

Sub CheckInput()

Rem declare variables
Dim intCheckVal As Integer
Dim i As Integer, j As Integer

Rem check if cell to check is numeric else leave sub
If Not IsNumeric(ActiveCell.Offset(0, -1)) Then Exit Sub
intCheckVal = ActiveCell.Offset(0, -1)
Rem set start values
i = 255
j = 259
Rem loop till the highest range to check
While Not i > 2359
  If Not (i < intCheckVal And intCheckVal < j) Then
    i = i + 300
    j = j + 300
  Else
Rem exit because the value was found in one of the ranges
    Exit Sub
  End If
Wend
Rem show the box
MsgBox "Please enter the data"
End Sub

this proc assumes you're using integer values for the ranges

HTH:O)Bruintje
0
 
LVL 45

Accepted Solution

by:
aikimark earned 23 total points
ID: 6905254
Select Case ActiveCell.Offset(0,-31).Value
  Case 0255 To 0258, 0555 To 0559, 0855 To 0859, 1155 To 1159, 1455 To 1459, 1755 To 1759, 2055 To 2059, 2355 To 2359
    If activecell.offset(0,-31).text = vbNullString Then
      Msgbox "Please enter the data"

End Select
0
 
LVL 16

Expert Comment

by:twalgrave
ID: 7754870
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in Community Support that this question is:
- points to aikimark
Please leave any comments here within the
next seven days.
0
 

Expert Comment

by:SpideyMod
ID: 7811796
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

914 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

16 Experts available now in Live!

Get 1:1 Help Now