+ Reply to Thread
Results 1 to 4 of 4

Error 1004 (application-defined) in my VBA code

Hybrid View

  1. #1
    Registered User
    Join Date
    10-15-2013
    Location
    Edmonton, Alberta Canada
    MS-Off Ver
    Excel 2010
    Posts
    21

    Error 1004 (application-defined) in my VBA code

    [CODE]

    Sub Find_Name()
    Dim Rng As Range
    FindString = InputBox("Employee Search(last, first):")
    If Trim(FindString) <> "" Then
    With Sheets("Active").Range("A:A")
    Set Rng = .Find(What:=FindString, _
    After:=.Cells(.Cells.Count), _
    LookIn:=xlValues, _
    LookAt:=xlWhole, _
    searchorder:=xlByRows, _
    searchdirection:=xlNext, _
    MatchCase:=False)
    If Not Rng Is Nothing Then
    Application.Goto Rng.Offset(0, -1), True DEBUGG HIGHLIGHTS this line?????
    Else
    MsgBox "Employee Not Found"
    End If
    End With
    End If
    End Sub

    I am using this code to find employees information in [Active] sheet.
    Attached Files Attached Files

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Error 1004 (application-defined) in my VBA code

    With Sheets("Active").Range("A:A")
    needs to be
    With ActiveSheet.Range("A:A")
    Also make sure to complete your code tags. You've got the first one but missed the [/CODE]
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Error 1004 (application-defined) in my VBA code

    If you searching column A, you can not go to the left of it.

    Application.Goto Rng.Offset(0, -1),

  4. #4
    Registered User
    Join Date
    10-15-2013
    Location
    Edmonton, Alberta Canada
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Error 1004 (application-defined) in my VBA code

    Thanks AB33 it works now !!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Getting Error 1004 Object or Application Defined Error - Code to rearrange data
    By BlazzedTroll in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 06-10-2013, 12:10 PM
  2. Error When Implementing Code: "1004 - Application-defined or object-defined error"
    By blueblazingdemon in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-10-2013, 11:21 AM
  3. [SOLVED] Error 1004: Application-defined or object-defined error on Range(Cells(x,y)) syntax
    By winch in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-04-2013, 11:02 AM
  4. [SOLVED] run-time error '1004' application-defined or object-defined error - Excel 2007
    By kaurka in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-06-2012, 02:46 AM
  5. Replies: 2
    Last Post: 09-12-2012, 01:01 PM

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