Results 1 to 6 of 6

Backwards compatibility issue between VB Excel 2010 -> 2003

Threaded View

  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:
    .Range("H2:H" & pRow).Formula = "=VLOOKUP(A2,All_Parts!$" & FirstRow & FirstCol & ":$" & LastRow & LastCol & ",2,FALSE)"
    The error I receive is a 1004 object defined error

    Here is the rest
    Dim UsedRng As Range
      Dim FirstRow As Long, LastRow As Long, FirstCol As Long, LastCol As Long, pRow As Long
         
        Set UsedRng = ActiveWorkbook.Sheets("All_Parts").UsedRange
        FirstRow = UsedRng(1).Row
        FirstCol = UsedRng(1).Column
        LastRow = UsedRng(UsedRng.Cells.Count).Row
        LastCol = UsedRng(UsedRng.Cells.Count).Column
     
     Application.StatusBar = "Validating, locations & confirming part numbers"
       
           With Sheets("Successful")
         'set the range to copy - this time, I'm using the postcode row 
         pRow = .Range("F" & Rows.Count).End(xlUp).Row
         .Range("F1:F" & pRow).AutoFilter Field:=1, Criteria1:="<>"
         'check the postcode
         .Range("G2:G" & pRow).Formula = "=IF(ISERROR(VLOOKUP(F2,Postcodes!$A$2:$A$855,1,FALSE)),""REMOTE"",""METRO"")"
         .Range("G2").AutoFilter
         'check the FRU
         '.Range("H2:H" & pRow).Formula = "=VLOOKUP(A2,All_Parts!$A$1:$B$1528,2,FALSE)" ' <- This works in 2003
         .Range("H2:H" & pRow).Formula = "=VLOOKUP(A2,All_Parts!$" & FirstRow & FirstCol & ":$" & LastRow & LastCol & ",2,FALSE)" ' <- This doesnt in 2003
         .Range("H2").AutoFilter

    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

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. 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