+ Reply to Thread
Results 1 to 7 of 7

Unable To Interate Through Cells In A Named Range

  1. #1
    Registered User
    Join Date
    01-20-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    25

    Unable To Interate Through Cells In A Named Range

    I'm trying to what I assumed would be a simple task, based on the fact that I've done very similar things in the past, but is coming up with an error I can't figure out. I have a combobox which I fill from a dynamic named range. When I select an item in the combobox, I want it to iterate through that range and then put the data from the next column into a text box.

    I get the generic Run-time error '1004': Application-defined or object-defined error on the bolded line of code. (This happens on the first iteration through the loop.)

    CurRow is set to 2 and CurCol is set to 1, which is the correct location for the first row of the cell. I'm sure the range is setup correctly because the combobox populates from it using the RowSource property and PartList is definitely the correct name for the sheet.

    What am I missing that could be causing this error?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Unable To Interate Through Cells In A Named Range

    Instead of Empty shouldn't that be "Empty" with double quotation mark?

  3. #3
    Registered User
    Join Date
    01-20-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Unable To Interate Through Cells In A Named Range

    No, Empty is a recognized keyword to signify a cell that has nothing in it.

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

    Re: Unable To Interate Through Cells In A Named Range

    try using Long variables rather than string ones.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  5. #5
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Unable To Interate Through Cells In A Named Range

    Why have you decided to use the Value2 property?
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  6. #6
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Unable To Interate Through Cells In A Named Range

    Good spot Andy, I didn't notice that until you pointed it out.

  7. #7
    Registered User
    Join Date
    01-20-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Unable To Interate Through Cells In A Named Range

    Quote Originally Posted by Andy Pope View Post
    try using Long variables rather than string ones.
    Ugh. That was it. For some reason, in an old project where I used similar code, I had declared them as strings initially and didn't realize that at some point I had redeclared them as integers. Thank you very much.


    Quote Originally Posted by Mordred View Post
    Why have you decided to use the Value2 property?
    To be honest, I'm not sure. I know I ran into some problem in an older project where I was required to use Value2 but I don't remember what that problem was anymore.

    I tested this new project with just .Value and it seems to work fine. (I'm predominately a VB.NET/PHP programmer, I've only recently dabbled in Excel/VBA in order to fix a couple of applications my company has been using far longer than I've been here.)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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