+ Reply to Thread
Results 1 to 20 of 20

Caputre WB name on error and continue

  1. #1
    Registered User
    Join Date
    08-27-2014
    Location
    Albany, NY
    MS-Off Ver
    Office 2010
    Posts
    91

    Caputre WB name on error and continue

    Below is the far too complex code I haven't whittled down yet. I have a routine that performs a copy-past from one workbook to a compiled workbook. Sometimes the source data is bad (ie, the source workbook thinks that 9 contiguous cells are non=contiguous BS error) When an error like this occurs, I want to be able to capture the WB name that popped the error then skip that workbook and continue. At the end I would like a Pop up of errored out WBs. Can this be done give what I have?

    Due to the sensitivity of the data, I cannot accurately recreate of share the files. The repetition for Risk A/B/C is due to the risk groups being contiguous in rows, but the same 5 categories...its a mess and i a trying to untagle it.

    Please Login or Register  to view this content.

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

    Re: Caputre WB name on error and continue

    Where do you get the error?

    Are you checking for the contigous cells?

    PS Couldn't you use a For/Next loop for the worksheets, perhaps with a step of 2?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    08-27-2014
    Location
    Albany, NY
    MS-Off Ver
    Office 2010
    Posts
    91

    Re: Caputre WB name on error and continue

    I get the error on this line from VBA.

    Please Login or Register  to view this content.
    I did not know I could check for contiguous cells. But it seems to be something with just certain workbooks...no merged cells or anything like that, It just thinks they aren't contiguous. I can post the exact error if needed. Would this be overkill if it is a tiny portion of the workbooks?

    PS , I could, still working out other bugs before I consolidate...I inherited this mess.

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

    Re: Caputre WB name on error and continue

    What exactly do you mean the workbook/code thinks the cells aren't contiguous?

    Does that line of code cause an error?

    Could the problem actually be with the copied range, copyBaseDataFrom?

    To check for contiguous cells in a range variable you could use the range's Areas property, if all the cells in the range were contiguous that will return 1.

  5. #5
    Registered User
    Join Date
    08-27-2014
    Location
    Albany, NY
    MS-Off Ver
    Office 2010
    Posts
    91

    Re: Caputre WB name on error and continue

    My company DL's a number of workbooks that are parsed out from a large database on a private site. We do not control the source workbooks until they are in our servers. That being said they are all the same layout and format but on some the range for copyDataBaseFrom (which will work on one WB won't work on another due to this contiguous cell issue.

    If it helps I have attached screen shots of the error box and the highlighted line it throws from.

    Like I said it works for 90% of the WBs for some reason it thinks on certain ones that the data is effed.

    Doc1.docx

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

    Re: Caputre WB name on error and continue

    What ranges do the 2 variables copyBaseDataFrom and copyBaseDataTo refer to when you get the error?

  7. #7
    Registered User
    Join Date
    08-27-2014
    Location
    Albany, NY
    MS-Off Ver
    Office 2010
    Posts
    91

    Re: Caputre WB name on error and continue

    the EXACT same ranges they do in other workbooks that work fine "A5" to "C5" and down to the last row with data in it.

    Please Login or Register  to view this content.

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

    Re: Caputre WB name on error and continue

    This should skip the pastespecial if copyBaseData is not a contiguous range and print the name of the workbook the problem was with to the debug window.
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    08-27-2014
    Location
    Albany, NY
    MS-Off Ver
    Office 2010
    Posts
    91

    Re: Caputre WB name on error and continue

    I tried that syntax using both CopyBaseDataFrom and copyBaseDataTo and I get and error that says argument is not optional

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

    Re: Caputre WB name on error and continue

    There was anothe typo/omission,
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    08-27-2014
    Location
    Albany, NY
    MS-Off Ver
    Office 2010
    Posts
    91

    Re: Caputre WB name on error and continue

    I appreciate the help, still throws the exact same error as before. Meh....i don't want to waste your time

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

    Re: Caputre WB name on error and continue

    I've got a feeling that error isn't caused by a non-contiguous range though obviously that's what the message says the problem is.

    Can you print the address of the 2 ranges to the debug window?

    To do that add this just before the PasteSpecial
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    08-27-2014
    Location
    Albany, NY
    MS-Off Ver
    Office 2010
    Posts
    91

    Re: Caputre WB name on error and continue

    kersmack. There is the issue...now to fix it since it works all the other damn times LOL

    From Range: $A$5:$C$9 to range $C$2

    No idea why this happens only with certsin WBs

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

    Re: Caputre WB name on error and continue

    Copying/pasting between those 2 ranges shouldn't be a problem.

    What happens if you add this just before the copy?

  15. #15
    Registered User
    Join Date
    08-27-2014
    Location
    Albany, NY
    MS-Off Ver
    Office 2010
    Posts
    91

    Re: Caputre WB name on error and continue

    I love a good mystery...what happens if I put What before the copy?

  16. #16
    Registered User
    Join Date
    08-27-2014
    Location
    Albany, NY
    MS-Off Ver
    Office 2010
    Posts
    91

    Re: Caputre WB name on error and continue

    I love a good mystery...what happens if I put What before the copy?

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

    Re: Caputre WB name on error and continue

    Oops, sorry about that.

    I meant this.
    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    08-27-2014
    Location
    Albany, NY
    MS-Off Ver
    Office 2010
    Posts
    91

    Re: Caputre WB name on error and continue

    Same error....tried it before both copyBaseData Variablese

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

    Re: Caputre WB name on error and continue

    So it's still the same error as the one in the image you posted?

  20. #20
    Registered User
    Join Date
    08-27-2014
    Location
    Albany, NY
    MS-Off Ver
    Office 2010
    Posts
    91

    Re: Caputre WB name on error and continue

    Yes It is....Frustratingly, yes

+ 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. Macro code to continue iterating if error.
    By sid9221 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-23-2013, 03:39 PM
  2. Continue to get Sub not defined error? Can anyone help?
    By cody4334 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-18-2012, 05:00 PM
  3. Replies: 4
    Last Post: 04-01-2011, 12:02 PM
  4. Code error, highlight error, continue to RUN
    By JohnSeito in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-07-2008, 01:29 AM
  5. VB Formula error in macro, How to Continue?
    By Mikeco in forum Excel General
    Replies: 7
    Last Post: 04-30-2008, 07:29 PM

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