+ Reply to Thread
Results 1 to 11 of 11

runtime error 1004 vb

  1. #1
    Registered User
    Join Date
    05-23-2013
    Location
    cambridge
    MS-Off Ver
    Excel 2003
    Posts
    12

    runtime error 1004 vb

    Hi

    Can anyone help me resolve an issue with the code below. I am getting a runtime error 1004, i highlighted the problem in the code. i am running excel 2007
    i appreciate any help

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: runtime error 1004 vb

    The syntax works if the range contains valid names and data in the current region

    Can you create the names manually using the same data?
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    05-23-2013
    Location
    cambridge
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: runtime error 1004 vb

    Andy,

    Thank you for replying, i tired to point it to the sheet, folder and range name, but it did not like RefersToRange and the .cells(i)..
    I am using this code in the module, it is used with a main() to populate a combobox with one of 3 named ranges depending on a cell value. The main() an setNmaes are on the module, and the combobox and the named ranges are in sheet1.
    Can you kindly help?

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: runtime error 1004 vb

    None of that makes sense, to me, in regards to the questions I asked.

    post example file

  5. #5
    Registered User
    Join Date
    05-23-2013
    Location
    cambridge
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: runtime error 1004 vb

    Quote Originally Posted by Andy Pope View Post
    None of that makes sense, to me, in regards to the questions I asked.

    post example file
    I have attached an example, thank you for your time much appreciated
    Attached Files Attached Files

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: runtime error 1004 vb

    Please Login or Register  to view this content.

    I think the problem with the code was the reference to combobox1 , which was not on the active sheet.
    And the setting the ListFillRange range to the cell address rather than the name which had been created. With only the cells part it would have to relative to the sheet with the control on.

  7. #7
    Registered User
    Join Date
    05-23-2013
    Location
    cambridge
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: runtime error 1004 vb

    Thanks Andy, i agree i missed that.
    I tried your code, but i am still getting a runtime error 1004
    this selection is not valid
    theTopLeft.CurrentRegion.CreateNames Top:=True, Left:=False, _
    Bottom:=False, Right:=False
    i suspect it is the refertorange not working, maybe i need an addin?
    I am a novice, so i don't know what i am doing yet
    Please help

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: runtime error 1004 vb

    If you are trying to run this from the command button on sheet3 then you will need to change the reference to Activesheet.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    05-23-2013
    Location
    cambridge
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: runtime error 1004 vb

    Thank you Andy,
    I am getting Error 1004 application-define or object define error from this: With theName.RefersToRange
    this is what i have on the module after the changes you recommended
    I think i am getting close, thanks to you. I hope you can help me figure it out

    Please Login or Register  to view this content.

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: runtime error 1004 vb

    So you did not bother to read the comment in the code?

    ' remaining code remove for brevity


    Here is the full code
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    05-23-2013
    Location
    cambridge
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: runtime error 1004 vb

    Sorry, i misunderstood. (i read the comment, i just didn't understand it)
    setNames is not defined in the Main()?

    Please excuse my ignorance, but i am trying

+ 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] VBA Error: Runtime Error 1004: AutoFilter method of Range class failed
    By jl22stac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2013, 07:27 PM
  2. [SOLVED] Range error in code, runs alone but not inside my full program, giving runtime error 1004
    By charizzardd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-23-2012, 03:34 PM
  3. runtime error 1004
    By crizzle in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-29-2008, 12:54 PM
  4. [SOLVED] runtime error 1004
    By valdesd in forum Excel General
    Replies: 2
    Last Post: 10-12-2005, 03:05 PM
  5. Excel 2003 Macro Error - Runtime error 1004
    By Cow in forum Excel General
    Replies: 2
    Last Post: 06-07-2005, 09:05 AM

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