Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Command Button

Posted on 2002-03-29
4
Medium Priority
?
147 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 46

Accepted Solution

by:
aikimark earned 92 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

705 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