+ Reply to Thread
Results 1 to 6 of 6

Backwards compatibility issue between VB Excel 2010 -> 2003

  1. #1
    Registered User
    Join Date
    02-05-2013
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2010
    Posts
    6

    Backwards compatibility issue between VB Excel 2010 -> 2003

    Hi All,
    Wondering if I can get some expert advice from someone on my issue.
    I've written some code for a script for slicing and dicing data which works perfectly in Excel 2010, but 2003 doesn't like it unfortunately.
    Probably an easy one for an expert set of eyes, but my lack of real experience in scripting is hurting me here is I do not understand why what I have written fails in excel 2003.

    The idea behind my code is that I'm searching a data set for parts in a given location; the output tells me if I have a part in a particular location based on the state and the part number.

    Here is my code (or part of) that I get the error on:
    Please Login or Register  to view this content.
    The error I receive is a 1004 object defined error

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

    The reason for using variables in the VLOOKUP is because data is regularly added to the "All_Parts" tab so I figured doing it this way would ensure that the VLOOKUP searches all new data.

    I've tried removing the $ signs from the line and reversing the "FirstRow" and "FirstCol"
    I can confirm that this line ".Range("H2:H" & pRow).Formula = "=VLOOKUP(A2,All_Parts!$A$1:$B$1528,2,FALSE)"" works when I test with it so I know its something to do with the variables or how I've written it.
    I've also considered my data sets, but they are all under 65535 lines so that shouldnt be an issue

    Any feedback would be appreciated and I thank you in advance !!

    All the best
    Steve
    Last edited by Leith Ross; 09-16-2013 at 08:13 PM. Reason: Added Code Tags

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Backwards compatibility issue between VB Excel 2010 -> 2003

    Hi Steve

    Please add Code Tags around your Code (must do)

    Please attach a sample file that represents what you have. The structure of your attachment should be the same structure as your actual data. Any proprietary information should be changed.

    Include in the attachment any code you're currently using (whether it works or not) and an "After" worksheet that demonstrates what you wish the output to be.

    To Attach a File:

    1. Click on Go Advanced
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the "Add Files"... button to locate your file for uploading.
    6. This will open a new window File Upload...Click "Select Files"
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the "Upload Files" button and wait until the file has uploaded.
    10. Click the "Done" Button.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Backwards compatibility issue between VB Excel 2010 -> 2003

    Hello Steve,

    I can't see how it can work in XL 2010.

    It fails probably because you're not specifying any column letters, just the row refs.

    But why not simplify things by defining a dynamic range name in the Excel App. which automatically adjusts to the amount of data in the AllParts tab, then use the range name in your formula rather than worrying about which are the first and last rows.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Steve

    Are you sure this is a version issue?

    I can't see anything in the code that is version specific.

    I think the problem might be with FirstCol/FirstRow/LastCol/LastRow.

    FirstCol and LastCol should be column letters.

    Also, in a cell reference the column comes first then the row.

    Perhaps you could use Cells?
    Please Login or Register  to view this content.
    Last edited by Norie; 09-16-2013 at 08:39 PM.
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    02-05-2013
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Backwards compatibility issue between VB Excel 2010 -> 2003

    Hello Richard and thanks for your prompt replies.
    To be honest I have about 6 weeks of VB experience now so I can't say I know anything about dynamic ranges, but I'll do some research.
    I'd appreciate any links that you might be able to send me that can point me in the right direction.

    Jaslake - thanks for your feedback also. I'll certainly keep your feedback in mind for future posts!!

    Thanks again

    Steve

  6. #6
    Registered User
    Join Date
    02-05-2013
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Backwards compatibility issue between VB Excel 2010 -> 2003

    Quote Originally Posted by Norie View Post
    Steve

    Are you sure this is a version issue?

    I can't see anything in the code that is version specific.

    I think the problem might be with FirstCol/FirstRow/LastCol/LastRow.

    FirstCol and LastCol should be column letters.

    Also, in a cell reference the column comes first then the row.

    Perhaps you could use Cells?
    Please Login or Register  to view this content.
    That did it !! - fixed my issue Norie - thanks so much for this information!!

    I'm still going to investigate further on the dynamic range also. I'm up for anything that will help me to simplify my code!
    Thankyou to all who provided feedback.
    Steve
    Last edited by IamSierraCharlie; 09-16-2013 at 08:56 PM. Reason: Spelling and Grammar

+ 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] Excel VBA 2003 2010 Compatibility with ExportAsFixedFormat
    By Max_Taylor in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-14-2012, 07:06 PM
  2. [SOLVED] Excel 2003 / 2010 compatibility
    By asgersax in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 11-30-2012, 10:46 AM
  3. Replies: 3
    Last Post: 10-05-2012, 11:10 AM
  4. Replies: 2
    Last Post: 08-16-2012, 07:31 PM
  5. [SOLVED] Backwards compatibility with Excel 2003 Calendar Control
    By Whiskey Tango Foxtrot in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-20-2006, 09:20 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