+ Reply to Thread
Results 1 to 4 of 4

passing a range name as a variable results in error 1004

  1. #1
    Registered User
    Join Date
    01-20-2013
    Location
    Kampala
    MS-Off Ver
    Excel 2007
    Posts
    9

    passing a range name as a variable results in error 1004

    Dear All,

    I am trying to dynamically access certain values from a sheet (store) from a dynamic ranges.

    I have a store into which raw materials are recorded with their expiry dates.
    Each material could have several different batches with different expiry dates. My goal is to comb all these to ensure that for each batch in the store the products are not expired or are not about to expire.

    Because i have like 8 raw materials each which has an indeterminate number of active batches. Writing static code looks like a job which can take as many as three days. Because of my consistent naming of ranges (A_Expiry, A_Batch, B_Expiry, B_Batch) I decided to access these named ranges using a variable
    Please Login or Register  to view this content.
    NOte ExpDate should recieve an array.
    Yes and the names of the range are valid and the variables translate correctly to the names of ranges
    Any body with any idea. Line with error is in code in bold

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,366

    Re: passing a range name as a variable results in error 1004

    Suggest you post a sample workbook with named ranges and code.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    01-20-2013
    Location
    Kampala
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: passing a range name as a variable results in error 1004

    TMShucks, thanks for the quick reply there. I gues i was just tired and couldnt think or may be wanted some support. It turned out to be an issue with naming after all. I tested the code in isolation (another template) and it worked showing me that the problem was with my template. Some of my names have special characters which excel rejected and for which i created modifications such as (_). I just have to track these modifications.

    Thank you again

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,366

    Re: passing a range name as a variable results in error 1004

    Fair enough, glad you have resolved the issue.


    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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] Passing a variable range to a formula
    By jacob@thepenpoint in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-10-2012, 06:44 PM
  2. Argument not optional error while passing value of variable between subs
    By asha3010 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 09-30-2010, 05:21 AM
  3. [SOLVED] Series Collection Results in Runtime Error 1004
    By Matthew Cunliffe in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-25-2006, 06:40 PM
  4. Run-time error 1004 on variable
    By Casey in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-27-2006, 07:46 PM
  5. Passing variable from userform to module error
    By mworth01 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-05-2005, 12:47 PM

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