Newbie problem for VBA/Excel user
Hello
I have been trying to create a simple macro in Excel but i am doing something wrong, obviously.
*********************************************
Sub Amount()
'
' Keyboard Shortcut: Ctrl+q
'
if (((Range("A1").Select < 15000) or ((Range"A1").Select > 400000)
Print "Too small or too large number"
End If
End Sub
*********************************************
I am typing a number in cell A1. If that number is larger than 400000 or smaller than 15000 then it should print something. When i run this macro VB gives a "method not valid without suitable object". Does anyone understand what the problem is? Your help is appreciated. Thanks
Re: Newbie problem for VBA/Excel user
Try this...(untested)
VB Code:
Sub Amount()
'
' Keyboard Shortcut: Ctrl+q
'
If Cell("A1").Value < 15000 OR Cell("A1").Value > 400000 Then
Print "Too small or too large number"
End If
End Sub
Re: Newbie problem for VBA/Excel user
is this an office development problem? if it is, go to the office development section of the forums and you'll find answers there
Re: Newbie problem for VBA/Excel user
In any event, Welcome to the Forum kokoullis :wave:
Re: Newbie problem for VBA/Excel user
Excel VBA question moved to Office Development
Re: Newbie problem for VBA/Excel user
Quote:
Originally Posted by kokoullis
If that number is larger than 400000 or smaller than 15000 then it should print something.
Do you really want it to physically print "Too small or too large number" onto a piece of paper?
Can you clarify whay your procedure should do to let the user know that the number entered is invalid.