totally newbie question about macros and programing it

  • Thread starter Thread starter Dexter
  • Start date Start date
D

Dexter

every day i have to calculate something on job so i got idea to make one
macro that will help me. in school i worked on Q-basic :) and i know
this shoudn't be problem with macro but dunno where to start so please
help me.
i have 4 variables:
first is size and goes from 25 < =35 or 35 < = 45 or 45 < = 55 ....
second is type has just three values A or B or C
third is quantity and it goes from 1-50
and forth is number from 5-20
i would like to make it to ask me to insert first value then second,
then third and fourth ...
so if first value is for example 37 second value is B to pick up price
for that value that is for example 59 multiple it with quantity value
and divide it by fourth value...
i hope i was clear with what i want
so any help
please
 
See if this will work for your needs...

Mark Ivey


Sub test()
Dim mySize As Integer
Dim myType As String
Dim myQuantity As Integer
Dim myNumber As Integer
Dim myResult As Long

mySize = InputBox("Input your desired size", "Input Size")
If mySize >= 25 And mySize <= 35 Then
myType = "A"
ElseIf mySize >= 36 And mySize <= 45 Then
myType = "B"
ElseIf mySize >= 46 And mySize <= 55 Then
myType = "C"
Else: myType = ""
MsgBox "Please input a size between 25 to 55"
Exit Sub
End If


myQuantity = InputBox("Input a quantity", "Input Quantity")
If myQuantity < 1 Or myQuantity > 50 Then
MsgBox "Please input a quantity between 1 to 50"
Exit Sub
End If


myNumber = InputBox("Input a number", "Input Number")
If myNumber < 5 Or myNumber > 20 Then
MsgBox "Please input a number between 5 to 20"
Exit Sub
End If


myResult = (mySize * myQuantity) / myNumber

MsgBox "Type: " & myType & vbCrLf & vbCrLf & _
"Result: " & myResult, vbOKOnly

End Sub
 
thank you!!its working perfect and i will make some modifications to
customize it for my needs
thank you
 

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