+ Reply to Thread
Results 1 to 14 of 14

I am using scripting dictionary method -If no data - need a message box -

  1. #1
    Forum Contributor
    Join Date
    09-06-2011
    Location
    northern ireland
    MS-Off Ver
    Excel 365
    Posts
    180

    I am using scripting dictionary method -If no data - need a message box -

    Please Login or Register  to view this content.
    So this is my code as above, but what it there is nothing in the data when I open the file ? It doesn't do anything apart from open the data file to extract the info from so how can I put something in here to say if no results obtained then have a message box appear to say "no data to import this month" and to exit the sub....

    Many thanks in advance
    Leanne
    Last edited by leanne2011; 02-03-2012 at 04:48 AM.

  2. #2
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: I am using scripting dictionary method -If no data - need a message box -

    Hey,

    Try this,

    Please Login or Register  to view this content.
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  3. #3
    Forum Contributor
    Join Date
    09-06-2011
    Location
    northern ireland
    MS-Off Ver
    Excel 365
    Posts
    180

    Re: I am using scripting dictionary method -If no data - need a message box -

    Thanks for the quick response - but I got it wrong. The code does not de bug but instead the data that I have called from a getopenfile name just remains open and does not finish the code the error handler wont work

  4. #4
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: I am using scripting dictionary method -If no data - need a message box -

    Can you post the whole code?

  5. #5
    Forum Contributor
    Join Date
    09-06-2011
    Location
    northern ireland
    MS-Off Ver
    Excel 365
    Posts
    180

    Re: I am using scripting dictionary method -If no data - need a message box -

    Hi - yes sure

    Please Login or Register  to view this content.

  6. #6
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: I am using scripting dictionary method -If no data - need a message box -

    Try this,

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    09-06-2011
    Location
    northern ireland
    MS-Off Ver
    Excel 365
    Posts
    180

    Re: I am using scripting dictionary method -If no data - need a message box -

    Hi

    I just tried it - I get a run time error 424 ? at this point


    Please Login or Register  to view this content.















    any ideas

  8. #8
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: I am using scripting dictionary method -If no data - need a message box -

    Try This,

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    09-06-2011
    Location
    northern ireland
    MS-Off Ver
    Excel 365
    Posts
    180

    Re: I am using scripting dictionary method -If no data - need a message box -

    Hello - many thanks for your help but its not working. I think you are concentrating on if there is no BEMSID then close the workbook but BEMSID will always be in the file which is why the file is remaining open. The scripting dictionary is specifically looking at x(i,4) for:

    Overtime
    Overtime On Saturday
    Overtime on Sunday
    Saturday Premium
    Sunday Premium
    Travel
    Travel Saturday
    Travel Sunday/Holiday

    Its when none of the above are within the file that I need the macro to close the weeklyFN workbook - does that make sense?

    Kind regards
    Leanne

  10. #10
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: I am using scripting dictionary method -If no data - need a message box -

    Are you trying to exit if the file you open has no data in it? If so, check if C1 is blank.
    Good luck.

  11. #11
    Forum Contributor
    Join Date
    09-06-2011
    Location
    northern ireland
    MS-Off Ver
    Excel 365
    Posts
    180

    Re: I am using scripting dictionary method -If no data - need a message box -

    the file will always have data in it - but I am specifically pulling out the

    Overtime
    Overtime On Saturday
    Overtime on Sunday
    Saturday Premium
    Sunday Premium
    Travel
    Travel Saturday
    Travel Sunday/Holiday

    It when there is no data specifically for x(i,4) for the above names

    Cheers

  12. #12
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: I am using scripting dictionary method -If no data - need a message box -

    Then I suspect you simply want to check the Count of the dictionary and exit if 0?

  13. #13
    Forum Contributor
    Join Date
    09-06-2011
    Location
    northern ireland
    MS-Off Ver
    Excel 365
    Posts
    180

    Re: I am using scripting dictionary method -If no data - need a message box -

    Hi

    How would I put that into code?

    Thanks
    Leanne

  14. #14
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: I am using scripting dictionary method -If no data - need a message box -

    Well actually, looking at your code, you already have
    Please Login or Register  to view this content.
    so you just need to add a message box
    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