Filtering macro fills a column of my sheet with #value error

  • Re: Filtering macro fills a column of my sheet with #value error


    Good news and bad news.


    Bad news - As I said I only tested code in Post #20 once. I just got a free minute so I tested it again and it failed.


    Good news - I tried another thing as well and it worked, but I will test umpteen more times before I post.

  • Re: Filtering macro fills a column of my sheet with #value error


    I think I have the solution.


    Firstly you need to use the amended UDF as per Post #20.


    Secondly put Calculate at the end of the main code as per code snippet below


    Code
    'CLEAR THE FILTERING
        Sheets("RFI_LOG").Select
        ActiveSheet.Range("$A$1:$I$270").AutoFilter Field:=3
        Sheets("DATA").Select
        Calculate  'ADDED THIS LINE HERE
        Application.ScreenUpdating = True
    
    
    End Sub


    And thirdly make sure to delete the workaround code.

  • Re: Filtering macro fills a column of my sheet with #value error


    Hi holycow,


    I've changed the code as per your proposal and the macro worked like a charm. It does not give that #VALUE error. BUT :spin:
    Yes, unfortunately there is a BUT. The problem is with the code snippet which I copy the table and paste it as a picture on the DATA sheet.


    There is no problem with the filtering cause I've controlled it with temporarily disabling the code which reverts the filtering back after I copy the table in DATA sheet. As all the formulas and the UDF is currently in working mode, the picture of the data table shall contain no problems. But though the table doesn't contain any #VALUE errors after filtering, the picture of the table shows #VALUE errors at those cells.


    Here is the picture after the filtering:
    [Blocked Image: http://img43.imageshack.us/img43/1905/mg0w.jpg]


    And this is the screen cap from the RFI_LOG sheet, which is filtered and where the values are linkted to the table in DATA sheet:
    [Blocked Image: http://img703.imageshack.us/img703/2963/bces.jpg]


    As you will notice, the main values in the filtered sheet does not contain any errors, and the values of the cells reflects exactly the same in the table of DATA sheet.
    I couldn't understand why this God damn table picture reflects #VALUE errors??

  • Re: Filtering macro fills a column of my sheet with #value error



    What is reason for the table being a bitmap as per commented ??? above?

  • Re: Filtering macro fills a column of my sheet with #value error


    Hi pal,


    The reason is simply I cut&paste this bitmap over my monthly charts that I derive from the data in RFI_LOG sheet. I haven't tried any another method than this and provided there is, I really dunno know. If you look at the chart sheets you will notice these bitmaps on the right top corner of the chart.


    Regards,

  • Re: Filtering macro fills a column of my sheet with #value error


    Fingers crossed :)


    Go back to your original UDF, ie take Application.Volatile out.


    Go back to your original button code as per below. I have just made a few minor changes.


  • Re: Filtering macro fills a column of my sheet with #value error


    Here are the results of the Excelian Jury :)


    Run-time error '1004'
    Microsoft Excel cannot paste data
    :rambo::rambo:

  • Re: Filtering macro fills a column of my sheet with #value error


    Upload latest workbook containing everything as per Post #26

  • Re: Filtering macro fills a column of my sheet with #value error


    Quote from holycow;683919

    Upload latest workbook containing everything as per Post #26


    Hi holycow,


    I've been under a surgery so I were away from everything for about 10 days. I'm home now for a recovery period, and just writing this lines to you so that you won't have bad things about me in your head. I will look where we have been stopped last time, and keep you informed in a couple of days. Thnx for your understanding and outstanding help.


    Regards,

  • Re: Filtering macro fills a column of my sheet with #value error


    Hi Holycow,


    I have looked thru our postings and worked a little bit on the problem, couldn't find a solution however found a workaround. After a successfull filtering via VBA and using Calculate command to eliminate the errors, I copy the table, paste it with column with options and then paste it again with preserving values and number formatting and then pasting it as a bitmap :))) A little bit struggling thing but it works. Please do find the workbook attached with my latest revisions on the coding. As you are an experienced programmer, you can find the code too long and may be unnecessary, therefore I highly appreciate provided you could support me to shorten it or optimize it (if it's possible for sure).


    Also I have created a seperate file (2D_EMAAR_DMS.xlsx) which we use to control opening and closing status of our log files, because our files resides in a shared folder in Dropbox. You'll see when you examine the coding.


    Regards and many thanks for your help and support. I'm on my ears to hear your comments and propositions.


    NOTE: I couldn't be able to attach my files to the forum, so you can download them from the below link


    https://www.dropbox.com/s/fmhr2xz1e17ko6d/MyExcelFiles.rar

  • Re: Filtering macro fills a column of my sheet with #value error


    Holy smoke,


    This

    Code
    Sub tst()
        m = cbMonth.ListIndex + 1
        If m = 13 Then
            moT = "CUMULATIVE"
        Else
            moT = UCase(Application.Text(DateSerial(2013, m, 1), "mmmm"))
            dm = Day(DateSerial(cbyear, m + 1, 0))
        End If
    End Sub


    can be a replacement for


  • Re: Filtering macro fills a column of my sheet with #value error


    Hi snb


    The initial problem in this thread was to sort out cell errors on filter so I was focused only on that. I did not worry about shortening existing code. Why look for more work?? Now the user has asked for shortening/optimising of code your suggestion has come at a good time. Thanks for the help :) it's always good to learn from you.

  • Re: Filtering macro fills a column of my sheet with #value error


    Hi archleo


    Just looking at the procedure BackupLog. There is quite a bit of shortening that can be done there but need to ask a question first.


    You have used this save code. Using this code the activeworkbook name changes upon save.


    Code
    ThisWorkbook.SaveAs defDir & fName


    Are you aware of this save code? By using this save code the activeworkbook does not change. You continue to have the same workbook open while it saves a copy to your specified location but carries on working in the original file. This is the method I would use for backups.


    Code
    ThisWorkbook.SaveCopyAs defDir & fName


    Try it in your workbook and see what you think.


    snb's code for the date values is a no brainer and you should change to that.


    Let's know how those changes go before we continue.

  • Re: Filtering macro fills a column of my sheet with #value error


    Hi snb,


    Thanks for the code. I'm not so new but also not so experienced in VBA, but I do understand the logic of it. I really learned a lot from this code. I do appreciate. Thnx my friend.

  • Re: Filtering macro fills a column of my sheet with #value error


    Hi Holycow,


    Yes I'm aware of the save code. If you have noticed, prior to this code I save my original workbook and after that I make a "saveas" copy. And also this backup code is triggered via Workbook.Close event. To eliminate any loop, I'm using a control cell with .Value = 1 and the value of this cell in the copied file ise 0, so that when you need to or accidentally open a backed up file, you don't mess anything.


    I'm now on my way changing my coding with snb's...


    Thnx for all your efforts...

  • Re: Filtering macro fills a column of my sheet with #value error


    Quote

    I'm now on my way changing my coding with snb's...


    snb is the master of short code, let's hope he sticks around ;)


    Quote

    I'm using a control cell with .Value = 1 and the value of this cell in the copied file ise 0, so that when you need to or accidentally open a backed up file, you don't mess anything


    Ok now I understand what the 0 and 1 do. Good idea of not messing up the backup file.

  • Re: Filtering macro fills a column of my sheet with #value error


    Quote from holycow;686707

    snb is the master of short code, let's hope he sticks around ;)


    Ok now I understand what the 0 and 1 do. Good idea of not messing up the backup file.


    Thnx for your appreciation bro. Most of the time, before writing any code, I prepare a story-board like text to realize what I want to do and opt out my options and criteria. Then I divide it into pieces and search for help files, uncle google and vba forums for a "dummy's guide on how to..." I also frequently use Mr.Excel's record macro option to see how it works. No need to open a new era, huh? :) As I'm not an IT guy or a programmer, and because of my working style described above, my code lines could be a little bit long, harsh and smokey :) Thanks for the novice guys like you, snb and others, I'm step by step learning the logic of constructing clean, optimised and understandable codes. Once again thanks a lot for your hands on improving and expanding my knowledge.

  • Re: Filtering macro fills a column of my sheet with #value error


    snb


    Quote

    snb's code for the date values is a no brainer and you should change to that


    Just in case that get's misinterpreted, I meant the question of which is the better code is a no brainer.


    archleo


    * Post deleted, need to rethink *

  • Re: Filtering macro fills a column of my sheet with #value error


    Quote

    ... As I'm not an IT guy or a programmer ...


    If that's the case you have done an excellent job on your workbook then.


    Here is a modified code for Workbook_BeforeClose



    And here is a modified code for BackupLog



    Quote

    ... Thanks for the novice, guys like you ...


    I'm not in the same league as the big guys on this site, I'm still on my P Plates, maybe even L Plates.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!