|
-
Mar 30th, 2006, 07:45 PM
#1
Thread Starter
New Member
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
-
Mar 30th, 2006, 08:03 PM
#2
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
-
Mar 30th, 2006, 08:10 PM
#3
Frenzied Member
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
On error goto Trap
Trap:
in case of emergency, drop the case...
****************************************
If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option. if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar
-
Mar 30th, 2006, 08:33 PM
#4
Re: Newbie problem for VBA/Excel user
In any event, Welcome to the Forum kokoullis
-
Mar 31st, 2006, 07:26 AM
#5
Re: Newbie problem for VBA/Excel user
Excel VBA question moved to Office Development
-
Mar 31st, 2006, 08:28 AM
#6
Re: Newbie problem for VBA/Excel user
 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.
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|