coding vba

  • Thread starter Thread starter paul
  • Start date Start date
P

paul

hwo do i write this into a VBA code
where i want variable A to be set to 4 if the variable B is greater or
equal to 14

otherwise it is to be set to 16 if the variable C lies between 5 and
10 otherwise it will be set to 9???
 
Sub kod()

Dim varA, varB, varC As Integer

On Error Resume Next

' varA, varB, varC should be initialized somehow

If varB >= 14 Then

varA = 4


ElseIf varC >= 5 And varC <= 10 Then
varA = 16

Else

varA = 9

End If


End Sub
 
The macro works as intended and exactly as Paul requested. Where is your
proof?
 
If B >= 14 then
A = 4
elseif C >= 5 then
If C <=10 then
A = 9
End If
End If
 
What is your purpose in being so snotty while, at the same time, ofering no
useful help for the one asking for assistance? Do you not know how to
achieve what he asked for?
 
Jim, you got the homework wrong.

That is setting A=9 if C is between 5 and 10 and doesn't set A otherwise.
 
Where is the number 16? "otherwise it is to be set to 16 if the variable C
lies between 5 and 10 otherwise it will be set to 9"
 
Sure I do. Snake answered it correctly.

What is the point of having somebody do your homework for you? Why bother
taking the class?
 
hwo do i write this into a VBA code
where i want variable A to be set to 4 if the variable B is greater or
equal to 14

otherwise it is to be set to 16 if the variable C lies between 5 and
10 otherwise it will be set to 9???

something like:

If B >= 14 Then
A = 4
ElseIf C > 5 And C < 10 Then
A = 16
Else
A = 9
End If
--ron
 

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