+ Reply to Thread
Results 1 to 5 of 5

Runtime Error '1004' Application-defined or object-defined error

  1. #1
    Forum Contributor
    Join Date
    05-20-2013
    Location
    Ann Arbor, MI
    MS-Off Ver
    Excel 2010
    Posts
    255

    Runtime Error '1004' Application-defined or object-defined error

    Hello,

    I'm currently getting this run time error whenever I try to run these lines of code when the user form is initialized. It's breaking at the if statement. (my spread sheet is only called read only, there are no restrictions on it.)

    With Worksheets("READ ONLY")
    If Not IsEmpty(.Range("F")) Then
    locationcb1.List = .Range("F", .Range("F" & Rows.Count).End(xlUp)).Value
    End If
    End With


    Please Help

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Runtime Error '1004' Application-defined or object-defined error

    You can't have Range("F"), if you want the whole column it needs to be Range("F:F")

    Edit: although I don't think isempty will work on more than one cell...

  3. #3
    Forum Contributor
    Join Date
    05-20-2013
    Location
    Ann Arbor, MI
    MS-Off Ver
    Excel 2010
    Posts
    255

    Re: Runtime Error '1004' Application-defined or object-defined error

    I got the code from the following thread : http://www.excelforum.com/excel-prog...-combobox.html

    why would it be any different?
    Sorry, I'm very new to vba

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Runtime Error '1004' Application-defined or object-defined error

    On that thread they have used
    Please Login or Register  to view this content.
    Which gives you a single cell, the value of which is "empty"

    If you use a Range of more than one cell, this will give you an array, with the value of each item in the array being "empty" but the value of the array itself is not "empty". So when you use isempty on a range with more than one cell it will return false.

    It should be simple to change it to do what you want, but just to check: where do you want it look to see if the cells are empty?

  5. #5
    Forum Contributor
    Join Date
    05-20-2013
    Location
    Ann Arbor, MI
    MS-Off Ver
    Excel 2010
    Posts
    255

    Re: Runtime Error '1004' Application-defined or object-defined error

    Nvm, I understand now. Thank you!

+ 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.6.0 RC 1