+ Reply to Thread
Results 1 to 8 of 8

Run Time Error in coding - Can someone help me debug please?

  1. #1
    Registered User
    Join Date
    07-10-2012
    Location
    Edinburgh
    MS-Off Ver
    Excel 2003
    Posts
    41

    Run Time Error in coding - Can someone help me debug please?

    I have attached an example file with a macro that strips data found in one column from matching data in another column.

    I get a run time error on the line:
    arrVariant = rngVariant.Cells(1, 1).Offset(1, 0).Resize(lngLastRow - 1, 1).Value

    Could someone help me fix the script please?

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    07-10-2012
    Location
    Edinburgh
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Run Time Error in coding - Can someone help me debug please?

    I'm pretty sure its the blanks in column E causing it. Sometimes, like column D, column E will have data and sometimes not. Any ideas?

  3. #3
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Run Time Error in coding - Can someone help me debug please?

    The variable lngLastRow contains a value of 1, so you're trying to resize the range to have zero rows.

    I'm not quite sure what you're trying to do, so I can't really tell you how to fix it, but if want to give me some more detail I'll have a go.

  4. #4
    Registered User
    Join Date
    07-10-2012
    Location
    Edinburgh
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Run Time Error in coding - Can someone help me debug please?

    So there are two columns that contain variant information, size and colour, columns D and E. The product model name, column G, also sometimes contains this data but I need to strip these words out where it does find a match in the variant columns. If you open the example attached you will see what I mean. It works if I populate row 2 & 3 in column E with some text.

    Thanks very much!

  5. #5
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Run Time Error in coding - Can someone help me debug please?

    OK, I think I understand.

    This is how I'd tackle that:

    Please Login or Register  to view this content.
    Does that help you out?

  6. #6
    Registered User
    Join Date
    07-10-2012
    Location
    Edinburgh
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Run Time Error in coding - Can someone help me debug please?

    That almost works a treat.

    Where there is no size or colour it removes the spaces from the product model name. Any way to modify it for that?

  7. #7
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Run Time Error in coding - Can someone help me debug please?

    Try changing this line:

    Please Login or Register  to view this content.
    To:

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    07-10-2012
    Location
    Edinburgh
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Run Time Error in coding - Can someone help me debug please?

    That works great. Thank you very much!

+ 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