+ Reply to Thread
Results 1 to 2 of 2

Thread: Application/Object defined error

  1. #1
    Registered User
    Join Date
    02-20-2011
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    3

    Question Application/Object defined error

    Hi All,

    I'm trying to add some code into my worksheet to simply scrolls down a list and paste the current date in the first empty cell. I keep getting the error "1004: Application or Object defined error" on the line where the cell is selected though, any ideas???

    Private Sub SpecedNotify_Click()
    
    Sheets("RSPS A-Ge").Select
    Range("E12").Select
    
    Do Until IsEmpty(Selection)
        Selection.Offset(1, 0).Select
    Loop
    
    Selection.Offset(0, 0).Value = DateValue(Now)
    
    Sheets("Reports").Select
    End Sub

  2. #2
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,226

    Re: Application/Object defined error

    Get in the habit now of not selecting and activating, VBA does not have this need. Address your commands fully (sheet + cell + additional movements + command) and you it works much more efficiently:

    Private Sub SpecedNotify_Click()
        Sheets("Sheet1").Range("E12").End(xlDown).Offset(1) = Date
    End Sub

    Or possibly:
    Private Sub SpecedNotify_Click()
        Sheets("Sheet1").Range("E" & Rows.Count).End(xlUp).Offset(1) = Date
    End Sub
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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