Results 1 to 6 of 6

Thread: Newbie problem for VBA/Excel user

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2006
    Posts
    1

    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

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Newbie problem for VBA/Excel user

    Try this...(untested)
    VB Code:
    1. Sub Amount()
    2. '
    3. ' Keyboard Shortcut: Ctrl+q
    4. '
    5. If Cell("A1").Value < 15000 OR Cell("A1").Value > 400000 Then
    6. Print "Too small or too large number"
    7. End If
    8. End Sub

  3. #3
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    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

  4. #4
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Newbie problem for VBA/Excel user

    In any event, Welcome to the Forum kokoullis

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Newbie problem for VBA/Excel user

    Excel VBA question moved to Office Development

  6. #6
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    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.
    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
  •  



Click Here to Expand Forum to Full Width