+ Reply to Thread
Results 1 to 2 of 2

Application-Defined or Object-Defined Error on simple code

  1. #1
    Fid
    Guest

    Application-Defined or Object-Defined Error on simple code

    I seem to continually struggle with this error anytime I write vba code
    for excel.

    I have the following code:

    Private Sub cmdUpdate_Click()

    Workbooks("Inventory").Worksheets("RawData").Columns("G").Replace
    What:="{01", Replacement:="Newton", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    End Sub

    This code runs when a user clicks a command button but always gives me
    the application-defined or object-defined error. Others who have
    tried to help me say they cannot replicate the error. Is anyone else
    struggling with this?

    Thanks,

    Brent


  2. #2
    Chip Pearson
    Guest

    Re: Application-Defined or Object-Defined Error on simple code

    If the button is on a worksheet, and you are in Excel97, change
    the TakeFocusOnClick property to False. This is a bug that was
    fixed in 2000.


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "Fid" <[email protected]> wrote in message
    news:[email protected]...
    >I seem to continually struggle with this error anytime I write
    >vba code
    > for excel.
    >
    > I have the following code:
    >
    > Private Sub cmdUpdate_Click()
    >
    > Workbooks("Inventory").Worksheets("RawData").Columns("G").Replace
    > What:="{01", Replacement:="Newton", LookAt:=xlPart, _
    > SearchOrder:=xlByRows, MatchCase:=False,
    > SearchFormat:=False, _
    > ReplaceFormat:=False
    > End Sub
    >
    > This code runs when a user clicks a command button but always
    > gives me
    > the application-defined or object-defined error. Others who
    > have
    > tried to help me say they cannot replicate the error. Is
    > anyone else
    > struggling with this?
    >
    > Thanks,
    >
    > Brent
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1