+ Reply to Thread
Results 1 to 4 of 4

Error handling when dynamic name range is empty

  1. #1
    Forum Contributor
    Join Date
    02-09-2010
    Location
    Constanta
    MS-Off Ver
    Excel 2007
    Posts
    128

    Error handling when dynamic name range is empty

    Greetings,

    The below macro creates a third list by concatenating two lists (Dynamic Ranges "Test" & "DB"). There could be three (which I can think of) situations that causes the code to error out.

    1. Both Test & DB are empty - Nothing to be done
    2. Test is empty but DB is not - Third list to be equal to DB
    3. DB is empty but Test is not - Third list to be equal to Test

    I tried to put in some error handling but it is not working as expected under different scenarios - I populated a range of cells with the values of the third list. Can someone please help me?

    Much appreciated
    Asha

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Error handling when dynamic name range is empty

    Hello asha3010,

    I made some changes to your macro. There is no need to trap the error as it can be avoided. It will now check if the range is empty by using the CountA function. This will return the number of cells that contain strings, numbers, dates, or formulae. If the range is empty, the macro jumps to Errhandler.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    02-09-2010
    Location
    Constanta
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: Error handling when dynamic name range is empty

    Hi Leith,

    Thanks for your prompt response. Sorry to say this but when both DB & Test ranges are empty, I get a run-time error 1004: application defined or object defined error with the following code highlighted in yellow

    Please Login or Register  to view this content.
    Any ideas why this is happening?

    Many thanks
    Asha

  4. #4
    Forum Contributor
    Join Date
    02-09-2010
    Location
    Constanta
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: Error handling when dynamic name range is empty

    Hi all,

    I have taken another stab at this and it seems to work but I am not sure if this is a very robust & efficient as I ended up writing additional code for three separate processes depending on the scenarios!

    Any suggestions in cleaning up the code would be greatly appreciated.

    Thanks again
    Asha

    Please Login or Register  to view this content.

+ 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