+ Reply to Thread
Results 1 to 2 of 2

Run-time error '1004' VBA Excel 2003

  1. #1
    Registered User
    Join Date
    07-19-2006
    Posts
    1

    Run-time error '1004' VBA Excel 2003

    Help. I'm fairly new to VBA and can not figure what the problem is.

    The following code gives me the run-time error '1004'.


    ThisWorkbook.Sheets("Next").Activate

    ' Find and remove "(Query 1 with OBNatAc5)" in headers
    Rows("1:1").Select
    Selection.Replace What:="(Query 1 with OBNatAc5)", Replacement:="", _
    LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
    SearchFormat:=False, ReplaceFormat:=False

  2. #2
    Dave Peterson
    Guest

    Re: Run-time error '1004' VBA Excel 2003

    What version of excel are you using?

    If you're using xl97 and running the code from a command button placed on a
    worksheet, then change that command button's .takefocusonclick property to
    false.

    =====
    if your code is behind a worksheet, try not to do the selecting:

    thisworkbook.sheets("next").Rows("1:1").Replace _
    What:="(Query 1 with OBNatAc5)", Replacement:="", _
    LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
    SearchFormat:=False, ReplaceFormat:=False



    pltang wrote:
    >
    > Help. I'm fairly new to VBA and can not figure what the problem is.
    >
    > The following code gives me the run-time error '1004'.
    >
    > ThisWorkbook.Sheets("Next").Activate
    >
    > ' Find and remove "(Query 1 with OBNatAc5)" in headers
    > Rows("1:1").Select
    > Selection.Replace What:="(Query 1 with OBNatAc5)", Replacement:="",
    > _
    > LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
    > SearchFormat:=False, ReplaceFormat:=False
    >
    > --
    > pltang
    > ------------------------------------------------------------------------
    > pltang's Profile: http://www.excelforum.com/member.php...o&userid=36552
    > View this thread: http://www.excelforum.com/showthread...hreadid=563042


    --

    Dave Peterson

+ 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