Visual basic code query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I’ve coded various items of data and assigned values to each item such that
when I produce a total I want to lookup a particular cell and check for the
total in it and then run a specific program associated with that total.

For example, when the total in, say, cell A50 is 60 I want it to trigger
application A, if 61 then application B etc.

So how would I write a Visual Basic program to: check the value of this cell
containing my total (which may be, for example, between 60 and 120) and then
run the program I have associated with that number?

Many thanks
 
Try something like this:

Sub test()
Select Case Range("A50").Value
Case 60
Call Application_A
Case 61
Call Application_B
'etc. ...
Case Else
' ...
End Select
End Sub

Regards,
Stefi


„Zakynthos†ezt írta:
 
You are welcome! Thanks for the feedback!
Stefi


„Zakynthos†ezt írta:
 
or

Sub test()
Select Case Range("g5").Value
Case Is < 60: Call aaaa
Case 60 To 120: Call bbbb
'etc. ...
Case Else
'...
End Select


End Sub
Sub aaaa()
MsgBox "a"
End Sub
Sub bbbb()
MsgBox "b"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top